Last active
December 14, 2020 14:40
-
-
Save PadreSVK/b59419c76a04e4f30275df1518d0abda to your computer and use it in GitHub Desktop.
Sample of solution wide additing git metadata to dlls and additing nuget version suffix for non master branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project Sdk="Microsoft.NET.Sdk"> | |
<PropertyGroup> | |
<StableVersionBranch>master</StableVersionBranch> | |
<!-- this should be defined in every csproj - if is not filled dont have affect on functioniality (nuget metadata) --> | |
<!-- <RepositoryUrl>https://github.com/XXXXX.git</RepositoryUrl>--> | |
</PropertyGroup> | |
<ItemGroup> | |
<PackageReference Include="GitInfo" Version="2.1.2"> | |
<PrivateAssets>all</PrivateAssets> | |
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> | |
</PackageReference> | |
</ItemGroup> | |
<!-- https://github.com/kzu/GitInfo/blob/main/src/GitInfo/build/GitInfo.targets#L544 --> | |
<Target Name="DecorateVersionsWithGitSha" AfterTargets="GitVersion"> | |
<PropertyGroup> | |
<!--https://docs.microsoft.com/en-us/dotnet/core/tools/csproj--> | |
<RepositoryCommit>$(GitSha)</RepositoryCommit> | |
<RepositoryBranch>$(GitBranch)</RepositoryBranch> | |
<InformationalVersion>$(GitBranch)-sha.$(GitSha)</InformationalVersion> | |
</PropertyGroup> | |
<!-- for pre release versions of nugets --> | |
<PropertyGroup Condition="'$(GitBranch)' != '$(StableVersionBranch)'"> | |
<!-- Add BuildNumber suffix or GitCommit is BuildNumber is empty --> | |
<Version Condition="$(BuildNumber) == ''" >$(Version)-pre$(GitCommit)</Version> | |
<Version Condition="$(BuildNumber) != ''" >$(Version)-pre$(BuildNumber)</Version> | |
<PackageVersion>$(Version)</PackageVersion> | |
</PropertyGroup> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment