blob: d744dedfd92563de97abc84111971c602b70a356 (
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
|
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' OR '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">
<!-- Tell ResolveMatchingContract to run and resolve contract to project reference -->
<ResolveMatchingContract>true</ResolveMatchingContract>
<NotSupportedSourceFile>$(IntermediateOutputPath)$(TargetName).notsupported.cs</NotSupportedSourceFile>
<CoreCompileDependsOn>$(CoreCompileDependsOn);GenerateNotSupportedSource</CoreCompileDependsOn>
<!-- Not supported sources are created from the ref assembly, we currently don't produce finalizers in dummmy assemblies, so we disable ApiCompat to not fail. -->
<RunApiCompat>false</RunApiCompat>
</PropertyGroup>
<ItemGroup Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' OR '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">
<AssemblyMetadata Include="NotSupported">
<Value>True</Value>
</AssemblyMetadata>
</ItemGroup>
<!-- GenerateNotSupportedSource
Inputs:
* A contract assembly
* Reference assemblies
Generates source for the contract that throws PlatformNotSupportedException
-->
<Target Name="GenerateNotSupportedSource"
DependsOnTargets="ResolveMatchingContract"
Inputs="@(ReferencePath);@(ResolvedMatchingContract)"
Outputs="$(NotSupportedSourceFile)">
<ItemGroup>
<!-- build out a list of directories where dependencies are located -->
<_referencePathDirectoriesWithDuplicates Include="@(ReferencePath->'%(RootDir)%(Directory)'->TrimEnd('\'))" />
<!-- strip metadata, removing duplicates -->
<_referencePathDirectories Include="%(_referencePathDirectoriesWithDuplicates.Identity)" />
</ItemGroup>
<Error Text="No single matching contract found." Condition="'@(ResolvedMatchingContract->Count())' != '1'" />
<PropertyGroup>
<GenAPIArgs>-assembly:"%(ResolvedMatchingContract.Identity)"</GenAPIArgs>
<GenAPIArgs>$(GenAPIArgs) -libPath:"@(_referencePathDirectories)"</GenAPIArgs>
<GenAPIArgs>$(GenAPIArgs) -out:"$(NotSupportedSourceFile)"</GenAPIArgs>
<GenAPIArgs Condition="'$(GeneratePlatformNotSupportedAssembly)' == 'true' OR '$(GeneratePlatformNotSupportedAssemblyMessage)' != ''">$(GenAPIArgs) -throw:"$(GeneratePlatformNotSupportedAssemblyMessage)"</GenAPIArgs>
<GenAPIArgs Condition="'$(GeneratePlatformNotSupportedAssemblyWithGlobalPrefix)' == 'true'">$(GenAPIArgs) -global</GenAPIArgs>
</PropertyGroup>
<PropertyGroup>
<GenAPICmd>$(ToolHostCmd) "$(ToolsDir)GenAPI.exe"</GenAPICmd>
</PropertyGroup>
<Exec Command="$(GenAPICmd) $(GenAPIArgs)" WorkingDirectory="$(ToolRuntimePath)" />
<ItemGroup>
<FileWrites Include="$(NotSupportedSourceFile)" />
<Compile Include="$(NotSupportedSourceFile)" />
</ItemGroup>
</Target>
</Project>
|