Skip to content

Commit c986ccf

Browse files
committed
Use GitInfo to generate the Version Info.
So lets' use the [GitInfo](https://github.com/devlooped/GitInfo) NuGet Package to generate the required version information for the assemblies in this repo. The base version is controlled from `GitInfo.txt`. This is where the version should be edited. The NuGet keeps track of the number of commits made since the `GitInfo.txt` was changed. So unless there is a major version change (or you run out of numbers) there should be no need to alter the version on a regular basis. All of the projects in the repo will then pick up the same version information was we will set the MSBuild `Version` property as well as the `InformationalVersion`. The latter will contain the git commit and branch.
1 parent eaec4e3 commit c986ccf

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Directory.Build.targets

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<ItemGroup>
3+
<PackageReference Include="GitInfo" Version="2.1.2" PrivateAssets="all" />
4+
</ItemGroup>
5+
<PropertyGroup>
6+
<GitThisAssembly>false</GitThisAssembly>
7+
<GitDefaultBranch>main</GitDefaultBranch>
8+
</PropertyGroup>
9+
10+
<Target Name="SetVersion" BeforeTargets="GetAssemblyVersion;GetPackageVersion" DependsOnTargets="GitVersion">
11+
<PropertyGroup>
12+
<Version>$(GitSemVerMajor).$(GitSemVerMinor).$(GitSemVerPatch)</Version>
13+
<InformationalVersion>$(Version); git-head: $(GitCommit) git-branch: $(GitBranch)</InformationalVersion>
14+
</PropertyGroup>
15+
</Target>
16+
</Project>

GitInfo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.0

0 commit comments

Comments
 (0)