summaryrefslogtreecommitdiff
path: root/Tools-Override/resolveContract.targets
blob: f8f98711f1552093916a121871db06984b18fb40 (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
<?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)/$(AssemblyName)/ref/$(AssemblyName).csproj</ContractProject>
      <HasMatchingContract Condition="'$(HasMatchingContract)' == '' and Exists('$(ContractProject)')">true</HasMatchingContract>
    </PropertyGroup>

    <ItemGroup Condition="'$(HasMatchingContract)' == 'true'">
      <!-- add contract project as project reference to get target path -->
      <ProjectReference 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>