forked from dotnet/SqlClient
/
NotSupported.targets
59 lines (50 loc) · 3.39 KB
/
NotSupported.targets
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
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" 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)$(AssemblyName).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>
<GenerateDocumentationFile Condition="'$(OSGroup)' != 'Windows_NT'">false</GenerateDocumentationFile>
</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"
AfterTargets="ResolveCodeAnalysisRuleSet"
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>
<GenAPIPath Condition="'$(MSBuildRuntimeType)' == 'core'"> "$(DotNetCmd) $(NuGetPackageRoot)microsoft.dotnet.genapi\$(MicrosoftDotNetGenApiPackageVersion)\tools\netcoreapp2.1\Microsoft.DotNet.GenAPI.dll"</GenAPIPath>
<GenAPIPath Condition="'$(MSBuildRuntimeType)' != 'core'"> "$(NuGetPackageRoot)microsoft.dotnet.genapi\$(MicrosoftDotNetGenApiPackageVersion)\tools\net472\Microsoft.DotNet.GenAPI.exe"</GenAPIPath>
</PropertyGroup>
<Exec Command="$(GenAPIPath) $(GenAPIArgs)" WorkingDirectory="$(ToolRuntimePath)" />
<ItemGroup>
<FileWrites Include="$(NotSupportedSourceFile)" />
<Compile Include="$(NotSupportedSourceFile)" />
</ItemGroup>
</Target>
</Project>