Skip to content

Commit

Permalink
Display version in the GUI using Git tag description
Browse files Browse the repository at this point in the history
  • Loading branch information
MirisWisdom committed Jan 6, 2019
1 parent a218c6d commit 627e3ea
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,5 @@ paket-files/

# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
*.pyc
VERSION
15 changes: 15 additions & 0 deletions src/YuMi.NieRexper.GUI/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System;
using System.ComponentModel;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using YuMi.NieRexper.GUI.Annotations;

Expand All @@ -45,6 +46,20 @@ public class Main : INotifyPropertyChanged
/// </summary>
private string _status = "PENDING";

/// <summary>
/// Returns data from the VERSION file.
/// </summary>
public string Version
{
get
{
var assembly = Assembly.GetExecutingAssembly();
using (var stream = assembly.GetManifestResourceStream("YuMi.NieRexper.GUI.VERSION"))
using (var reader = new StreamReader(stream))
return reader.ReadToEnd().TrimEnd();
}
}

/// <summary>
/// Selected save slot.
/// </summary>
Expand Down
7 changes: 7 additions & 0 deletions src/YuMi.NieRexper.GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@
<Label Content="{Binding Status}"
HorizontalContentAlignment="Right" />
</DockPanel>

<!-- Version -->
<DockPanel Margin="0,1,0,0">
<Label Content="Version" />
<Label Content="{Binding Version}"
HorizontalContentAlignment="Right" />
</DockPanel>
</StackPanel>
</StackPanel>
</TabItem>
Expand Down
8 changes: 8 additions & 0 deletions src/YuMi.NieRexper.GUI/YuMi.NieRexper.GUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,15 @@
<ItemGroup>
<Resource Include="Resources\Background.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="VERSION">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PreBuildEvent>git describe --tags &gt; "$(ProjectDir)\VERSION"</PreBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down

0 comments on commit 627e3ea

Please sign in to comment.