blob: 4e654bfec935e526504cf4b1eb79adb1a874d7bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!-- Import this .targets file to automatically generate AssemblyVersion
attribute according to DotNetOpenAuth convention.
This file assumes DotNetOpenAuth.props and DotNetOpenAuth.targets are also imported. -->
<PropertyGroup>
<VersionCsFile>$(IntermediatePath)\$(AssemblyName).Version.cs</VersionCsFile>
<NoWarn>$(NoWarn);1607</NoWarn>
<UltimateResourceFallbackLocation Condition=" '$(UltimateResourceFallbackLocation)' == '' ">UltimateResourceFallbackLocation.MainAssembly</UltimateResourceFallbackLocation>
</PropertyGroup>
<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/>
<Target Name="GetBuildVersion">
<GetBuildVersion Condition=" '$(BuildVersion)' == '' "
VersionFile="$(ProjectRoot)src\version.txt"
GitRepoRoot="$(ProjectRoot)">
<Output TaskParameter="Version" PropertyName="BuildVersion" />
<Output TaskParameter="SimpleVersion" PropertyName="BuildVersionSimple" />
<Output TaskParameter="PrereleaseVersion" PropertyName="PrereleaseVersion" />
<Output TaskParameter="MajorMinorVersion" PropertyName="MajorMinorVersion" />
<Output TaskParameter="GitCommitId" PropertyName="GitCommitId" />
<Output TaskParameter="BuildNumber" PropertyName="BuildNumber" />
</GetBuildVersion>
<PropertyGroup>
<!-- In TeamCity, the build agent doesn't get the .git directory, but the commit id is available by other means. -->
<GitCommitId Condition=" '$(GitCommitId)' == '' ">$(BUILD_VCS_NUMBER)</GitCommitId>
<GitCommitIdShort Condition=" '$(GitCommitId)' != '' ">.$(GitCommitId.Substring(0,10))</GitCommitIdShort>
<SemVerBuildSuffix>+build.$(BuildNumber)$(GitCommitIdShort)</SemVerBuildSuffix>
<AssemblyInformationalVersion>$(BuildVersionSimple)$(PrereleaseVersion)$(SemVerBuildSuffix)</AssemblyInformationalVersion>
<!-- When NuGet supports SemVer 2.0, we can set NuGetPackageVersion to be the same as $(AssemblyInformationalVersion) -->
<NuGetPackageVersion Condition=" '$(PrereleaseVersion)' == '' ">$(BuildVersion)</NuGetPackageVersion>
<NuGetPackageVersion Condition=" '$(PrereleaseVersion)' != '' ">$(BuildVersionSimple)$(PrereleaseVersion)</NuGetPackageVersion>
</PropertyGroup>
<Warning Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Unable to determine the git HEAD commit ID to use for informational version number." />
<Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(GitCommitId)"/>
<Message Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Building version $(BuildVersion)"/>
<Message Importance="low" Text="AssemblyInformationalVersion: $(AssemblyInformationalVersion)" />
<Message Importance="low" Text="NuGetPackageVersion: $(NuGetPackageVersion)" />
</Target>
<Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion">
<PropertyGroup>
<NewVersionCsFile>$(VersionCsFile).new</NewVersionCsFile>
</PropertyGroup>
<MakeDir Directories="$(IntermediatePath)"/>
<AssemblyInfo OutputFile="$(NewVersionCsFile)" CodeLanguage="C#"
AssemblyVersion="$(MajorMinorVersion)"
AssemblyFileVersion="$(BuildVersion)"
AssemblyInformationalVersion="$(AssemblyInformationalVersion)"
AssemblyTitle="$(AssemblyName)"
AssemblyProduct="DotNetOpenAuth"
NeutralResourcesLanguage="en-US"
UltimateResourceFallbackLocation="$(UltimateResourceFallbackLocation)"
GenerateClass="true" />
<!-- Avoid applying the newly generated AssemblyInfo.cs file to the build
unless it has changed in order to allow for incremental building. -->
<CompareFiles OriginalItems="$(VersionCsFile)" NewItems="$(NewVersionCsFile)">
<Output TaskParameter="AreChanged" PropertyName="AssemblyInfoChanged" />
</CompareFiles>
<Copy Condition=" '$(AssemblyInfoChanged)' == 'true' " SourceFiles="$(NewVersionCsFile)" DestinationFiles="$(VersionCsFile)" />
<ItemGroup>
<Compile Include="$(VersionCsFile)" />
</ItemGroup>
</Target>
</Project>
|