-
Notifications
You must be signed in to change notification settings - Fork 1
/
SharedBuildProperties.props
53 lines (52 loc) · 2.87 KB
/
SharedBuildProperties.props
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
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="Exists('CompiledTemplates.snk')">
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)CompiledTemplates.snk</AssemblyOriginatorKeyFile>
<DefineConstants>$(DefineConstants);STRONGNAME</DefineConstants>
</PropertyGroup>
<Import Project="SharedBuildProperties.props.user" Condition="Exists('SharedBuildProperties.props.user')" />
<Target Name="VersionInject" BeforeTargets="PrepareForBuild"
Condition=" !$(DefineConstants.Contains('NOASSEMBLYVERSION')) ">
<!-- get revision number -->
<Exec Command="git.exe describe" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="AVI_GitTag" />
</Exec>
<!-- get old version string -->
<ReadLinesFromFile File="Properties\AssemblyInfoVersion.cs">
<Output TaskParameter="Lines" PropertyName="AVI_Old"/>
</ReadLinesFromFile>
<!-- get base version number and construct new version string -->
<XmlPeek XmlInputPath="$(MSBuildThisFileDirectory)NuGet\$(MSBuildProjectName).nuspec" Query="/package/metadata/version/text()">
<Output TaskParameter="Result" PropertyName="AVI_Ver" />
</XmlPeek>
<PropertyGroup>
<AVI_Idx>$(AVI_Ver.IndexOf(`-`))</AVI_Idx>
</PropertyGroup>
<PropertyGroup Condition="$(AVI_Idx) >= 0"><!-- pre-release -->
<AVI_Suffix>$(AVI_Ver.Substring($(AVI_Idx)))</AVI_Suffix>
<AVI_Ver>$(AVI_Ver.Substring(0,$(AVI_Idx)))</AVI_Ver>
</PropertyGroup>
<PropertyGroup>
<AVI_Rgx>^$(AVI_Ver.Replace(`.`,`\.`))\.(\d+)$(AVI_Suffix)($|-\d+-g([0-9a-f]+))</AVI_Rgx>
<AVI_Rev>$([System.Text.RegularExpressions.Regex]::Match($(AVI_GitTag),$(AVI_Rgx)).Groups.get_Item(1))</AVI_Rev>
<AVI_Commit>$([System.Text.RegularExpressions.Regex]::Match($(AVI_GitTag),$(AVI_Rgx)).Groups.get_Item(3))</AVI_Commit>
<AVI_Ver>$(AVI_Ver).$(AVI_Rev)</AVI_Ver>
</PropertyGroup>
<PropertyGroup Condition=" '$(AVI_Commit)' != '' ">
<AVI_Commit>, commit $(AVI_Commit)</AVI_Commit>
</PropertyGroup>
<PropertyGroup>
<AVI_New>[assembly:System.Reflection.AssemblyFileVersion("$(AVI_Ver)"),<!--
-->System.Reflection.AssemblyInformationalVersion("$(AVI_Ver)$(AVI_Suffix)$(AVI_Commit)")]</AVI_New>
</PropertyGroup>
<Error Text="Tag $(AVI_GitTag) does not match .nuspec version $(AVI_Ver)" Condition=" '$(AVI_Rev)' == '' " />
<!-- rewrite version file if version changed -->
<WriteLinesToFile File="Properties\AssemblyInfoVersion.cs" Overwrite="true" Lines="$(AVI_New)"
Condition=" '$(AVI_Old)' != '$(AVI_New)' " />
<!-- create the item dynamically to prevent spurious rebuilds -->
<ItemGroup>
<Compile Include="Properties\AssemblyInfoVersion.cs" />
</ItemGroup>
</Target>
</Project>