-
-
Notifications
You must be signed in to change notification settings - Fork 208
/
Directory.Build.targets
87 lines (75 loc) · 4.51 KB
/
Directory.Build.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<Project>
<!--
Note: The following platform-specific properties need to be set in both Directory.Build.props and DirectoryBuild.targets.
TODO: Figure out how to consolidate to a single location.
- Directory.Build.props will get imported at the beginning of the project files, so sets properties that are
prerequisites for the build and can be overriden in the project files.
- Directory.Build.targets will get imported at the end of the project files, so can be used to run common custom
tasks or ultimately override properties set in Directory.Build.props or the project files.
-->
<PropertyGroup>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'ios'">12.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="'$(TargetPlatformIdentifier)' == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="'$(TargetPlatformIdentifier)' == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'android'">
<Compile Remove="**\*.Android.cs" />
<Compile Remove="**\Android\**\*.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'ios' And '$(TargetPlatformIdentifier)' != 'maccatalyst'">
<!-- Exclude our platform-specific code: -->
<Compile Remove="**\*.Cocoa.cs" />
<Compile Remove="**\Cocoa\**\*.cs" />
<!-- Maui device test projects have these too: -->
<Compile Remove="**\*.iOS.cs" />
<Compile Remove="**\iOS\**\*.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetPlatformIdentifier)' != 'windows'">
<Compile Remove="**\*.Windows.cs" />
<Compile Remove="**\Windows\**\*.cs" />
</ItemGroup>
<!-- Allow setting CLSCompliant via property in any csproj -->
<ItemGroup>
<AssemblyAttribute Include="CLSCompliantAttribute" Condition="'$(CLSCompliant)' == 'true'">
<_Parameter1>true</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<Target Name="OnlyTargetInstalledWorkloads" BeforeTargets="BeforeBuild" Condition="'$(WorkloadList)' == ''">
<Exec Command="dotnet workload list" ConsoleToMSBuild="true" StandardOutputImportance="Low" EchoOff="true">
<Output TaskParameter="ConsoleOutput" PropertyName="WorkloadList"/>
</Exec>
<PropertyGroup>
<AndroidWorkloadVersion>$([System.Text.RegularExpressions.Regex]::Match($(WorkloadList), "\s*(android)\s+(\S+)\s+SDK\s+([0-9\.]+).+").Groups[3].Value)</AndroidWorkloadVersion>
<IosWorkloadVersion>$([System.Text.RegularExpressions.Regex]::Match($(WorkloadList), "\s*(ios)\s+(\S+)\s+SDK\s+([0-9\.]+).+").Groups[3].Value)</IosWorkloadVersion>
<MacCatalystWorkloadVersion>$([System.Text.RegularExpressions.Regex]::Match($(WorkloadList), "\s*(maccatalyst)\s+(\S+)\s+SDK\s+([0-9\.]+).+").Groups[3].Value)</MacCatalystWorkloadVersion>
<MauiWorkloadVersion>$([System.Text.RegularExpressions.Regex]::Match($(WorkloadList), "\s*(maui)\s+(\S+)\s+SDK\s+([0-9\.]+).+").Groups[3].Value)</MauiWorkloadVersion>
</PropertyGroup>
<!-- Disable mobile targets if workloads aren't installed. -->
<PropertyGroup Condition="'$(AndroidWorkloadVersion)' == ''">
<NO_ANDROID>true</NO_ANDROID>
</PropertyGroup>
<PropertyGroup Condition="'$(IosWorkloadVersion)' == ''">
<NO_IOS>true</NO_IOS>
</PropertyGroup>
<PropertyGroup Condition="'$(MacCatalystWorkloadVersion)' == ''">
<NO_MACCATALYST>true</NO_MACCATALYST>
</PropertyGroup>
<PropertyGroup Condition="'$(MauiWorkloadVersion)' == ''">
<NO_WINDOWS>true</NO_WINDOWS>
</PropertyGroup>
</Target>
<!-- Workaround for https://github.com/xamarin/xamarin-macios/issues/15897 -->
<Target Name="_SetPublishFolderTypeNoneOnDocFileItems"
BeforeTargets="_ComputePublishLocation"
Condition="'$(OutputType)' == 'Exe' And ('$(TargetPlatformIdentifier)' == 'ios' Or '$(TargetPlatformIdentifier)' == 'maccatalyst')">
<ItemGroup>
<ResolvedFileToPublish
Update="@(ResolvedFileToPublish)"
Condition="'%(ResolvedFileToPublish.Extension)' == '.xml' And '%(ResolvedFileToPublish.PublishFolderType)' == ''"
PublishFolderType="None" />
</ItemGroup>
</Target>
</Project>