A huge plus of GitInfo project is that besides the library itself you don’t need anything else
For dotnet core projects, I enable support Git and make the first commit and after I add Git Tag "0.1.0".
Then I add NuGet package "GitInfo"
Next step you need to add AssemblyInfo.cs, better to Properties folder
using System.Reflection;
[assembly: AssemblyVersion (ThisAssembly.Git.BaseVersion.Major + "." + ThisAssembly.Git.BaseVersion.Minor + "." + ThisAssembly.Git.BaseVersion.Patch)]
[assembly: AssemblyFileVersion (ThisAssembly.Git.SemVer.Major + "." + ThisAssembly.Git.SemVer.Minor + "." + ThisAssembly.Git.SemVer.Patch)]
[assembly: AssemblyInformationalVersion (
ThisAssembly.Git.SemVer.Major + "." +
ThisAssembly.Git.SemVer.Minor + "." +
ThisAssembly.Git.Commits + "-" +
ThisAssembly.Git.Branch + "+" +
ThisAssembly.Git.Commit)]
And last step change csproj, you need add 3 rows
<PropertyGroup> <GenerateAssemblyInfo>false</GenerateAssemblyInfo> </PropertyGroup>
After that, you can use GitInfo and versioning anywhere
Good luck!!!
No comments:
Post a Comment