summaryrefslogtreecommitdiffstats
path: root/tools/DotNetOAuth.Versioning.targets
diff options
context:
space:
mode:
Diffstat (limited to 'tools/DotNetOAuth.Versioning.targets')
-rw-r--r--tools/DotNetOAuth.Versioning.targets36
1 files changed, 36 insertions, 0 deletions
diff --git a/tools/DotNetOAuth.Versioning.targets b/tools/DotNetOAuth.Versioning.targets
new file mode 100644
index 0000000..35d5f71
--- /dev/null
+++ b/tools/DotNetOAuth.Versioning.targets
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <!-- Import this .targets file to automaticaly generate AssemblyVersion
+ attribute according to DotNetOAuth convention. -->
+ <PropertyGroup>
+ <ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..</ProjectRoot>
+ <VersionCsFile>$(ProjectRoot)\obj\$(Configuration)\$(AssemblyName).Version.cs</VersionCsFile>
+ </PropertyGroup>
+
+ <Import Project="$(ProjectRoot)\lib\DotNetOpenId.BuildTasks.targets" />
+ <UsingTask AssemblyFile="$(ProjectRoot)\lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/>
+
+ <Target Name="GetBuildVersion">
+ <GetBuildVersion VersionFile="$(ProjectRoot)\src\version.txt" Condition=" '$(BuildVersion)' == '' ">
+ <Output TaskParameter="Version" PropertyName="BuildVersion" />
+ </GetBuildVersion>
+ <Message Text="Building version $(BuildVersion)"/>
+ </Target>
+
+ <Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion">
+ <PropertyGroup>
+ <NewVersionCsFile>$(VersionCsFile).new</NewVersionCsFile>
+ </PropertyGroup>
+ <MakeDir Directories="$(ProjectRoot)\obj\$(Configuration)"/>
+ <AssemblyInfo OutputFile="$(NewVersionCsFile)" CodeLanguage="C#" AssemblyVersion="$(BuildVersion)" />
+ <!-- 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>