summaryrefslogtreecommitdiff
path: root/packages/microsoft.dotnet.buildtools/2.1.0-rc1-03006-01/lib/resolveContract.targets
blob: 1bce2266d31964d47b7772aeaf0e52eac941402a (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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup Condition="'$(ResolveMatchingContract)' == 'true'">
    <AddProjectReferencesDynamicallyDependsOn>
      ResolveMatchingContract;
      $(AddProjectReferencesDynamicallyDependsOn);
    </AddProjectReferencesDynamicallyDependsOn>
    <ResolveReferencesDependsOn>
      $(ResolveReferencesDependsOn);
      VerifyMatchingContract
    </ResolveReferencesDependsOn>
  </PropertyGroup>

  <Target Name="ResolveMatchingContract">
    <PropertyGroup>
      <ContractProject Condition="'$(ContractProject)' == ''">$(SourceDir)/$(MSBuildProjectName)/ref/$(MSBuildProjectName).csproj</ContractProject>
      <HasMatchingContract Condition="'$(HasMatchingContract)' == '' and Exists('$(ContractProject)')">true</HasMatchingContract>
      <ContractAssemblyPath Condition="'$(ContractAssemblyPath)' == ''">$(ContractOutputPath)/$(MSBuildProjectName).dll</ContractAssemblyPath>
    </PropertyGroup>

    <ItemGroup Condition="'$(HasMatchingContract)' == 'true'">
      <ResolvedMatchingContract Condition="Exists('$(ContractAssemblyPath)')" Include="$(ContractAssemblyPath)" />

      <!-- If the contract doesn't exist in the default contract output path add a project reference to the contract project to resolve -->
      <ProjectReference Condition="'@(ResolvedMatchingContract)' == ''" Include="$(ContractProject)">
        <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
        <OutputItemType>ResolvedMatchingContract</OutputItemType>
      </ProjectReference>
    </ItemGroup>
  </Target>

  <Target Name="VerifyMatchingContract">
    <Error Condition="'$(HasMatchingContract)' == 'true' and !Exists('%(ResolvedMatchingContract.Identity)')" Text="ResolveMatchingContract could not find a matching contract '%(ResolvedMatchingContract.Identity)' not found." />
  </Target>
</Project>