1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <PropertyGroup Condition="'$(ResolveMatchingContract)' == 'true'">
5 <AddProjectReferencesDynamicallyDependsOn>
6 ResolveMatchingContract;
7 $(AddProjectReferencesDynamicallyDependsOn);
8 </AddProjectReferencesDynamicallyDependsOn>
9 <ResolveReferencesDependsOn>
10 $(ResolveReferencesDependsOn);
11 VerifyMatchingContract
12 </ResolveReferencesDependsOn>
15 <Target Name="ResolveMatchingContract">
17 <ContractProject Condition="'$(ContractProject)' == ''">$(SourceDir)/$(MSBuildProjectName)/ref/$(MSBuildProjectName).csproj</ContractProject>
18 <HasMatchingContract Condition="'$(HasMatchingContract)' == '' and Exists('$(ContractProject)')">true</HasMatchingContract>
19 <ContractAssemblyPath Condition="'$(ContractAssemblyPath)' == ''">$(ContractOutputPath)/$(MSBuildProjectName).dll</ContractAssemblyPath>
22 <ItemGroup Condition="'$(HasMatchingContract)' == 'true'">
23 <ResolvedMatchingContract Condition="Exists('$(ContractAssemblyPath)')" Include="$(ContractAssemblyPath)" />
25 <!-- If the contract doesn't exist in the default contract output path add a project reference to the contract project to resolve -->
26 <ProjectReference Condition="'@(ResolvedMatchingContract)' == ''" Include="$(ContractProject)">
27 <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
28 <OutputItemType>ResolvedMatchingContract</OutputItemType>
33 <Target Name="VerifyMatchingContract">
34 <Error Condition="'$(HasMatchingContract)' == 'true' and !Exists('%(ResolvedMatchingContract.Identity)')" Text="ResolveMatchingContract could not find a matching contract '%(ResolvedMatchingContract.Identity)' not found." />