Git hash wird angezeigt und gespeichert

This commit is contained in:
Husky
2020-02-20 21:42:24 +01:00
parent 954ffb4bc8
commit 183646b4da
4 changed files with 43 additions and 0 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@
/KanSan.Base/bin/*
/KanSan.Base/kansan.db
/KanSan.Base/obj/*
/KanSan/version.txt

View File

@@ -6,6 +6,16 @@
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<None Remove="version.txt" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="version.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ilmerge" Version="3.0.29" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.1">
@@ -25,4 +35,8 @@
<ProjectReference Include="..\KanSan.Base\KanSan.Base.csproj" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git rev-parse HEAD &gt;&quot;$(ProjectDir)\version.txt" />
</Target>
</Project>

View File

@@ -27,6 +27,7 @@ namespace KanSan
public MainWindow()
{
InitializeComponent();
this.Title = ProgrammHashVersion.GIT_HASH;
UnitOfWork unitOfWork = new UnitOfWork(new KanSanContext());
var d = unitOfWork.KundenRepository.Get().First();

View File

@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Text;
namespace KanSan
{
public static class ProgrammHashVersion
{
public static string GIT_HASH
{
get
{
string gitVersion;
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("KanSan.version.txt"))
using (StreamReader reader = new StreamReader(stream))
{
gitVersion = reader.ReadToEnd();
}
return gitVersion;
}
}
}
}