1 <?xml version="1.0" encoding="utf-8"?>
2 <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
3 <!-- Import this .targets file to automatically generate AssemblyVersion
4 attribute according to DotNetOpenAuth convention.
5 This file assumes DotNetOpenAuth.props and DotNetOpenAuth.targets are also imported. -->
7 <VersionCsFile>$(IntermediatePath)\$(AssemblyName).Version.cs</VersionCsFile>
8 <NoWarn>$(NoWarn);1607</NoWarn>
11 <UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/>
13 <Target Name="GetBuildVersion">
14 <GetBuildVersion Condition=" '$(BuildVersion)' == '' "
15 VersionFile="$(ProjectRoot)src\version.txt"
16 GitRepoRoot="$(ProjectRoot)">
17 <Output TaskParameter="Version" PropertyName="BuildVersion" />
18 <Output TaskParameter="SimpleVersion" PropertyName="BuildVersionSimple" />
19 <Output TaskParameter="GitCommitId" PropertyName="AssemblyInformationalVersion" />
22 <!-- In TeamCity, the build agent doesn't get the .git directory, but the commit id is available by other means. -->
23 <AssemblyInformationalVersion Condition=" '$(AssemblyInformationalVersion)' == '' ">$(BUILD_VCS_NUMBER)</AssemblyInformationalVersion>
25 <Warning Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Unable to determine the git HEAD commit ID to use for informational version number." />
26 <Message Condition=" '$(AssemblyInformationalVersion)' != '' " Text="Building version $(BuildVersion) from commit $(AssemblyInformationalVersion)"/>
27 <Message Condition=" '$(AssemblyInformationalVersion)' == '' " Text="Building version $(BuildVersion)"/>
30 <Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion">
32 <NewVersionCsFile>$(VersionCsFile).new</NewVersionCsFile>
34 <MakeDir Directories="$(IntermediatePath)"/>
35 <AssemblyInfo OutputFile="$(NewVersionCsFile)" CodeLanguage="C#"
36 AssemblyVersion="$(BuildVersion)"
37 AssemblyInformationalVersion="$(AssemblyInformationalVersion)" />
38 <!-- Avoid applying the newly generated AssemblyInfo.cs file to the build
39 unless it has changed in order to allow for incremental building. -->
40 <CompareFiles OriginalItems="$(VersionCsFile)" NewItems="$(NewVersionCsFile)">
41 <Output TaskParameter="AreChanged" PropertyName="AssemblyInfoChanged" />
43 <Copy Condition=" '$(AssemblyInfoChanged)' == 'true' " SourceFiles="$(NewVersionCsFile)" DestinationFiles="$(VersionCsFile)" />
45 <Compile Include="$(VersionCsFile)" />