summaryrefslogtreecommitdiffstats
path: root/tools/DotNetOpenAuth.targets
blob: d27fbdcaa07a47c607cf0e8a8e53649b12f1bdc8 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
	<Import Project="DotNetOpenAuth.Versioning.targets" />
	<Import Project="JavascriptPacker.targets" />
	<UsingTask AssemblyFile="$(ProjectRoot)lib\MSBuild.Community.Tasks.dll" TaskName="ILMerge"/>

	<!-- Prevent our own item types from appearing in Solution Explorer. -->
	<ItemDefinitionGroup>
		<SignDependsOn>
			<Visible>false</Visible>
		</SignDependsOn>
		<DelaySignedAssemblies>
			<Visible>false</Visible>
		</DelaySignedAssemblies>
	</ItemDefinitionGroup>

	<PropertyGroup>
		<CodeContractsInstallDir>$(ProjectRoot)tools\Contracts\</CodeContractsInstallDir>
		<DefineConstants Condition=" '$(SignAssembly)' == 'true' ">$(DefineConstants);StrongNameSigned</DefineConstants>
		<DefineConstants Condition=" '$(ClrVersion)' == '4' ">$(DefineConstants);CLR4</DefineConstants>
		<AssemblySearchPaths>$(ProjectRoot)lib;$(AssemblySearchPaths)</AssemblySearchPaths>
		<AssemblySearchPaths Condition="Exists('$(ProjectRoot)lib\net-$(TargetFrameworkVersion)')">$(ProjectRoot)lib\net-$(TargetFrameworkVersion);$(AssemblySearchPaths)</AssemblySearchPaths>
	</PropertyGroup>

	<ItemGroup>
		<DelaySignedAssemblies Include="$(TargetPath)" Condition=" '$(SuppressTargetPathDelaySignedAssembly)' != 'true' "/>
	</ItemGroup>

	<ItemGroup Condition=" '$(ClrVersion)' != '4' and '$(NoCodeContracts)' != 'true' ">
		<Reference Include="Microsoft.Contracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=736440c9b414ea16, processorArchitecture=MSIL">
			<SpecificVersion>False</SpecificVersion>
			<HintPath>..\..\lib\Microsoft.Contracts.dll</HintPath>
		</Reference>
	</ItemGroup>

	<!-- This forces a build break when Code Contracts are not installed. -->
	<PropertyGroup>
		<CompileDependsOn>$(CompileDependsOn);CheckForCodeContracts</CompileDependsOn>
	</PropertyGroup>
	<Target Name="CheckForCodeContracts">
		<Error Condition=" '$(CodeContractsImported)' != 'true' " Text="This project requires Code Contracts. Please install from: http://msdn.microsoft.com/en-us/devlabs/dd491992.aspx" />
	</Target>

	<!-- This is our multi-targeting aware shadow assembly generator. -->
	<UsingTask AssemblyFile="$(ProjectRoot)\lib\DotNetOpenAuth.BuildTasks.dll" TaskName="Publicize" />
	<PropertyGroup>
		<ResolveReferencesDependsOn>
			$(ResolveReferencesDependsOn);
			CreatePublicAccessors
		</ResolveReferencesDependsOn>
	</PropertyGroup>
	<!-- Remove the built-in shadow generator, since we do it ourselves to avoid bugs in the Microsoft code. -->
	<Target Name="CreatePublicAccessors">
		<PropertyGroup>
			<VSVersionForTargetFramework>v10.0</VSVersionForTargetFramework>
			<VSVersionForTargetFramework Condition=" '$(ClrVersion)' != '4' ">v9.0</VSVersionForTargetFramework>
		</PropertyGroup>
		<Publicize
			Condition=" '%(ReferencePath.Shadow)' == 'true' "
			SkipUnchangedFiles="true"
			MSBuildExtensionsPath="$(MSBuildExtensionsPath)"
			ToolPath="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\$(VSVersionForTargetFramework)\TeamTest"
			Assembly="@(ReferencePath)"
			DelaySign="$(DelaySign)"
			KeyFile="$(PublicKeyFile)">
			<Output TaskParameter="AccessorAssembly" ItemName="ReferencePath" />
		</Publicize>
	</Target>

	<Target Name="Sign" DependsOnTargets="@(SignDependsOn)" Outputs="@(SignedDependencies);@(SignedAssemblyTargets)" Condition=" '@(DelaySignedAssemblies)' != '' ">
		<!-- Make sure that all dependencies are also signed. -->
		<MSBuild Projects="@(ProjectReference)" Targets="Sign" BuildInParallel="$(BuildInParallel)">
			<Output TaskParameter="TargetOutputs" ItemName="SignedDependencies"/>
		</MSBuild>

		<!-- Add the resource assemblies. -->
		<ItemGroup>
			<!-- Make sure that we consider the TargetPath's satellites even if TargetPath itself was suppressed. -->
			<DelaySignedAssembliesForSatellites Include="@(DelaySignedAssemblies)" />
			<DelaySignedAssembliesForSatellites Include="$(TargetPath)" Condition=" '$(SuppressTargetPathDelaySignedAssembly)' == 'true' "/>
		</ItemGroup>
		<PropertyGroup>
			<DelaySignedSatelliteAssembliesPattern>@(DelaySignedAssembliesForSatellites->'%(RootDir)%(Directory)*\%(FileName).resources.*')</DelaySignedSatelliteAssembliesPattern>
		</PropertyGroup>
		<ItemGroup>
			<DelaySignedSatelliteAssemblies Include="$(DelaySignedSatelliteAssembliesPattern)" />
			<DelaySignedSatelliteAssemblies>
				<CultureDir>$([System.IO.Path]::GetFileName($([System.IO.Path]::GetDirectoryName('%(Directory)'))))\</CultureDir>
			</DelaySignedSatelliteAssemblies>
		</ItemGroup>

		<!-- Don't sign assemblies in place.  Lots of reasons for this, not the least of which is that
		     subsequent builds of web site projects will cause the satellite assemblies to be regenerated (bizarre)
				 and erase the signature. -->
		<ItemGroup>
			<AssembliesToSign Include="@(DelaySignedAssemblies);@(DelaySignedSatelliteAssemblies)" />
			<SignedAssemblyTargets Include="@(AssembliesToSign->'%(RootDir)%(Directory)$(SignedSubPath)%(FileName)%(Extension)')">
				<UnsignedAssemblyPath>%(AssembliesToSign.Identity)</UnsignedAssemblyPath>
				<SymbolPath Condition="Exists('%(RootDir)%(Directory)%(FileName).pdb')">%(RootDir)%(Directory)%(FileName).pdb</SymbolPath>
			</SignedAssemblyTargets>
		</ItemGroup>

		<Message Text="Signing delay-signed assemblies using key pair container $(KeyPairContainer)." />
		<Copy SourceFiles="@(AssembliesToSign)" DestinationFiles="@(SignedAssemblyTargets)" />
		<ReSignDelaySignedAssemblies
			KeyContainer="$(KeyPairContainer)"
			Assemblies="@(SignedAssemblyTargets)"
			Condition="Exists(%(Identity))" />
	</Target>

	<Target Name="ResignDelaySignedAssemblies" Outputs="@(ResignedAssembliesOutputs)">
		<ItemGroup>
			<DelaySignedProjects Include="
													 @(ProductProjects);
													 $(ProjectRoot)src\dotnetopenauth\dotnetopenauth.proj;
													 $(ProjectRoot)src\dotnetopenauth.test\dotnetopenauth.test.csproj;
													 $(ProjectRoot)samples\openidofflineprovider\openidofflineprovider.csproj;
													 " />
		</ItemGroup>
		<MSBuild Projects="@(DelaySignedProjects)" Targets="Sign" BuildInParallel="$(BuildInParallel)">
			<Output TaskParameter="TargetOutputs" ItemName="ResignedAssembliesOutputs"/>
		</MSBuild>
	</Target>

	<Target Name="GetOutputPath" Outputs="$(OutputPath)" />

	<Import Condition="'$(CodeContractsImported)' != 'true' AND ('$(DontImportCodeContracts)' != 'true' or '$(ImportCodeContractsFromToolset)' == 'true')" Project="$(CodeContractsInstallDir)\MsBuild\v4.0\Microsoft.CodeContracts.targets"/>
</Project>