summaryrefslogtreecommitdiffstats
path: root/tools/DotNetOpenId.Versioning.targets
blob: 87a411a072452656047937c5d19f194533562ed7 (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
<?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 DotNetOpenId convention. -->
	<PropertyGroup>
		<ProjectRoot Condition="'$(ProjectRoot)' == ''">$(MSBuildProjectDirectory)\..\..</ProjectRoot>
		<VersionCsFile>$(ProjectRoot)\obj\$(Configuration)\$(AssemblyName).Version.cs</VersionCsFile>
	</PropertyGroup>

	<Import Project="$(ProjectRoot)\tools\DotNetOpenId.BuildTasks.targets" />
	<UsingTask AssemblyFile="$(ProjectRoot)\lib\MSBuild.Community.Tasks.dll" TaskName="AssemblyInfo"/>

	<Target Name="GetBuildVersion" DependsOnTargets="BuildCustomTasks">
		<GetBuildVersion VersionFile="$(ProjectRoot)\src\version.txt">
			<Output TaskParameter="Version" PropertyName="BuildVersion" />
		</GetBuildVersion>
		<Message Text="Building version $(BuildVersion)"/>
	</Target>
	
	<Target Name="BeforeBuild" DependsOnTargets="GetBuildVersion">
		<MakeDir Directories="$(ProjectRoot)\obj\$(Configuration)"/>
		<AssemblyInfo OutputFile="$(VersionCsFile)" CodeLanguage="C#" AssemblyVersion="$(BuildVersion)" />
		<ItemGroup>
			<Compile Include="$(VersionCsFile)" />
		</ItemGroup>
	</Target>
</Project>