Switch to MinVer for versioning

上级 a7ded296
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.202
# Visual Studio Version 17
VisualStudioVersion = 17.5.33516.290
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}"
EndProject
......@@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
Targets\GenerateNativeDllName.targets = Targets\GenerateNativeDllName.targets
nuget.config = nuget.config
version.json = version.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeLibraryLoadTestApp.x86", "NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj", "{86453D2C-4953-4DF4-B12A-ADE579608BAA}"
......
......@@ -17,6 +17,8 @@
<PackageIcon>square-logo.png</PackageIcon>
<PackageLicenseFile>App_Readme/LICENSE.md</PackageLicenseFile>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<MinVerDefaultPreReleaseIdentifiers>preview.0</MinVerDefaultPreReleaseIdentifiers>
<MinVerBuildMetadata Condition="'$(libgit2_hash)' != ''">libgit2-$(libgit2_hash.Substring(0,7))</MinVerBuildMetadata>
</PropertyGroup>
<ItemGroup>
......@@ -32,15 +34,15 @@
<ItemGroup>
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.319]" PrivateAssets="none" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="all" />
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="all" />
</ItemGroup>
<Import Project="..\Targets\CodeGenerator.targets" />
<Import Project="..\Targets\GenerateNativeDllName.targets" />
<Target Name="SetNuSpecProperties" BeforeTargets="GenerateNuspec" DependsOnTargets="GetBuildVersion">
<Target Name="SetNuspecProperties" BeforeTargets="GenerateNuspec">
<PropertyGroup>
<PackageReleaseNotes>https://github.com/libgit2/libgit2sharp/blob/$(GitCommitIdShort)/CHANGES.md#libgit2sharp-changes</PackageReleaseNotes>
<PackageReleaseNotes>https://github.com/libgit2/libgit2sharp/blob/$(SourceRevisionId)/CHANGES.md</PackageReleaseNotes>
</PropertyGroup>
</Target>
......
using System.Globalization;
using System.Reflection;
using LibGit2Sharp.Core;
namespace LibGit2Sharp
......@@ -22,7 +23,14 @@ internal static Version Build()
/// <summary>
/// Returns version of the LibGit2Sharp library.
/// </summary>
public virtual string InformationalVersion => ThisAssembly.AssemblyInformationalVersion;
public virtual string InformationalVersion
{
get
{
var attribute = Assembly.GetExecutingAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>();
return attribute.InformationalVersion;
}
}
/// <summary>
/// Returns all the optional features that were compiled into
......@@ -55,7 +63,7 @@ private string RetrieveAbbrevShaFrom(string sha)
/// </summary>
/// <para>
/// The format of the version number is as follows:
/// <para>Major.Minor.Patch[-previewTag]+{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features)</para>
/// <para>Major.Minor.Patch[-previewTag]+libgit2-{libgit2_abbrev_hash}.{LibGit2Sharp_hash} (arch - features)</para>
/// </para>
/// <returns></returns>
public override string ToString()
......
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Target Name="DefineProperties">
<PropertyGroup>
<SourceRevisionIdPath>$(IntermediateOutputPath)SourceRevisionId.txt</SourceRevisionIdPath>
<UniqueIdentifierPath>$(IntermediateOutputPath)UniqueIdentifier.g.cs</UniqueIdentifierPath>
<AssemblyCommitIdsPath>$(IntermediateOutputPath)AssemblyCommitIds.g.cs</AssemblyCommitIdsPath>
</PropertyGroup>
</Target>
<Target Name="WriteSourceRevisionIdToFile" AfterTargets="AddSourceRevisionToInformationalVersion" DependsOnTargets="DefineProperties">
<WriteLinesToFile File="$(SourceRevisionIdPath)" Lines="$(SourceRevisionId)" Overwrite="true" WriteOnlyWhenDifferent="true" />
<ItemGroup>
<FileWrites Include="$(SourceRevisionIdPath)" />
</ItemGroup>
</Target>
<Target Name="GenerateUniqueIdentifierCs" Inputs="$(VersionSourceFile)" Outputs="$(UniqueIdentifierPath)" BeforeTargets="CoreCompile" AfterTargets="GenerateAssemblyVersionInfo" DependsOnTargets="DefineProperties">
<Target Name="GenerateUniqueIdentifierCs" Inputs="$(SourceRevisionIdPath)" Outputs="$(UniqueIdentifierPath)" BeforeTargets="CoreCompile" AfterTargets="WriteSourceRevisionIdToFile" DependsOnTargets="DefineProperties">
<PropertyGroup>
<UniqueIdentifier>$([System.Guid]::NewGuid())</UniqueIdentifier>
<UniqueIdentifier Condition="'$(GitCommitId)' != ''">$(GitCommitId)</UniqueIdentifier>
<UniqueIdentifier>$(SourceRevisionId)</UniqueIdentifier>
<UniqueIdentifier Condition="'$(UniqueIdentifier)' == ''">$([System.Guid]::NewGuid())</UniqueIdentifier>
<UniqueIdSourceLines>
namespace LibGit2Sharp.Core
{
......@@ -34,24 +36,12 @@
<Compile Include="$(UniqueIdentifierPath)" />
<FileWrites Include="$(UniqueIdentifierPath)" />
</ItemGroup>
</Target>
<Target Name="AddNativeDllCommitShaToBuildMetadata" BeforeTargets="GetBuildVersion">
<ItemGroup>
<BuildMetadata Include="libgit2-$(libgit2_hash.Substring(0,7))" />
</ItemGroup>
</Target>
<Target Name="GenerateAssemblyCommitIdsCs" Inputs="$(libgit2_propsfile);$(VersionSourceFile)" Outputs="$(AssemblyCommitIdsPath)" BeforeTargets="CoreCompile" AfterTargets="GenerateAssemblyVersionInfo" DependsOnTargets="DefineProperties">
<Target Name="GenerateAssemblyCommitIdsCs" Inputs="$(libgit2_propsfile);$(SourceRevisionIdPath)" Outputs="$(AssemblyCommitIdsPath)" BeforeTargets="CoreCompile" AfterTargets="WriteSourceRevisionIdToFile" DependsOnTargets="DefineProperties">
<PropertyGroup>
<LibGit2SharpCommitSha>unknown</LibGit2SharpCommitSha>
<LibGit2SharpCommitSha Condition="'$(GitCommitId)' != ''">$(GitCommitId)</LibGit2SharpCommitSha>
<LibGit2SharpCommitSha>$(SourceRevisionId)</LibGit2SharpCommitSha>
<LibGit2SharpCommitSha Condition="'$(LibGit2SharpCommitSha)' == ''">unknown</LibGit2SharpCommitSha>
<AssemblyCommitIdsSourceLines>
namespace LibGit2Sharp
{
......@@ -70,7 +60,6 @@
<Compile Include="$(AssemblyCommitIdsPath)" />
<FileWrites Include="$(AssemblyCommitIdsPath)" />
</ItemGroup>
</Target>
</Project>
<Project>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<Target Name="DefineNativeDllName">
<PropertyGroup>
<NativeDllNamePath>$(IntermediateOutputPath)NativeDllName.g.cs</NativeDllNamePath>
......@@ -30,4 +26,5 @@
<FileWrites Include="$(NativeDllNamePath)" />
</ItemGroup>
</Target>
</Project>
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.27.0-preview.{height}",
"publicReleaseRefSpec": [
"^refs/heads/master$", // we release out of master
"^refs/heads/maint/v\\d+(?:\\.\\d+)?$" // and maint/vNN branches
],
"cloudBuild": {
"buildNumber": {
"enabled": true
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册