forked from unoplatform/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
uno.winui.common.targets
215 lines (178 loc) · 9.89 KB
/
uno.winui.common.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<SourceGeneratorBasePath Condition="'$(SourceGeneratorBasePath)'==''">..\</SourceGeneratorBasePath>
<UnoUIMSBuildTasksTargetPath Condition="'$(UnoUIMSBuildTasksTargetPath)'==''"></UnoUIMSBuildTasksTargetPath>
<_IsUnoPlatform>true</_IsUnoPlatform>
</PropertyGroup>
<Target Name="ValidateUnoUIAndUnoWinUIExclusion" BeforeTargets="BeforeBuild">
<Error Code="UNOB0001"
Text="Cannot build with both Uno.WinUI and Uno.UI nuget packages referenced."
Condition="'$(PkgUno_UI)'!='' and '$(PkgUno_WinUI)'!=''" />
</Target>
<Import Project="$(SourceGeneratorBasePath)Uno.UI.SourceGenerators.props" />
<Import Project="$(UnoUIMSBuildTasksTargetPath)Uno.UI.Tasks.targets" />
<Target Name="_UnoWinUICommonFeatureDefines" AfterTargets="PrepareForBuild">
<!--
Defines Uno features.
Note to contributors: Adding a feature here allows for smoother upgrade
to a more recent version of uno. These constants are defined in the code
that uses Uno, so conditional compilation can be used to detect the presence
of breaking changes.
-->
<PropertyGroup>
<DefineConstants>$(DefineConstants);HAS_UNO</DefineConstants>
<DefineConstants Condition="$(_IsUnoWinUIPackage)">$(DefineConstants);HAS_UNO_WINUI</DefineConstants>
<DefineConstants>$(DefineConstants);UNO_HAS_FRAMEWORKELEMENT_MEASUREOVERRIDE</DefineConstants>
<DefineConstants>$(DefineConstants);UNO_HAS_NO_IDEPENDENCYOBJECT</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETStandard' or '$(TargetFrameworkIdentifier)'=='.NETCoreApp'">
<DefineConstants>$(DefineConstants);UNO_REFERENCE_API</DefineConstants>
</PropertyGroup>
</Target>
<Target Name="ReplaceRefAssemblies" AfterTargets="_ResolveAssemblies" Condition="'$(AndroidApplication)'=='true'">
<!-- This is a workaround for https://github.com/xamarin/xamarin-android/issues/1162#issuecomment-359475008 -->
<ItemGroup>
<ResolvedAssembliesFixedWindows Include="@(ResolvedAssemblies->Replace('\ref\','\lib\'))" />
<ResolvedAssembliesFixedUnix Include="@(ResolvedAssemblies->Replace('/ref/','/lib/'))" />
<ResolvedAssembliesFixed Include="@(ResolvedAssembliesFixedWindows)" Condition="@(ResolvedAssembliesFixedWindows) != @(ResolvedAssemblies)" />
<ResolvedAssembliesFixed Include="@(ResolvedAssembliesFixedUnix)" Condition="@(ResolvedAssembliesFixedUnix) != @(ResolvedAssemblies)" />
<ResolvedAssemblies Condition="'@(ResolvedAssembliesFixed->Count())' > 0" Remove="@(ResolvedAssemblies)" />
<ResolvedAssemblies Include="@(ResolvedAssembliesFixed)" />
</ItemGroup>
</Target>
<ItemGroup>
<!-- Properties that will be automatically forwarded to the source generators -->
<UnoSourceGeneratorAdditionalProperty Include="UnoRemoteControlPort" />
<UnoSourceGeneratorAdditionalProperty Include="UnoRemoteControlHost" />
<UnoSourceGeneratorAdditionalProperty Include="UnoRemoteControlProcessorsPath" />
</ItemGroup>
<!-- List of packages that provide an uno-runtime folder -->
<ItemGroup>
<UnoRuntimeEnabledPackage Include="Uno.UI" PackageBasePath="$(MSBuildThisFileDirectory).." Condition="!$(_IsUnoWinUIPackage)" />
<UnoRuntimeEnabledPackage Include="Uno.WinUI" PackageBasePath="$(MSBuildThisFileDirectory).." Condition="$(_IsUnoWinUIPackage)" />
</ItemGroup>
<!-- Backward compatibility validation -->
<Target Name="_ValidateTopLevelPackageWasmUpgrade"
Condition="'$(IsUnoHead)'!='true' and '$(WasmHead)'!=''"
BeforeTargets="BeforeBuild">
<Error Text="WebAssembly head projects need to be updated to use the [Uno.UI.WebAssembly] package instead of the [Uno.UI] NuGet package." />
</Target>
<!--
Cross-runtime libraries creation targets
-->
<Target Name="PrepareUnoRuntimeProjectReferences" BeforeTargets="BeforeBuild">
<!--
Build the ProjectReference item group for UnoRuntimeProjectReference items.
The references are added as non-referencing ProjectReferences to enable the inclusion
of their output in the final nuget package.
-->
<ItemGroup>
<ProjectReference Include="%(UnoRuntimeProjectReference.Identity)">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
<UndefineProperties>TargetFramework</UndefineProperties>
</ProjectReference>
</ItemGroup>
</Target>
<Target Name="ResolvePrepareUnoRuntimeProjectReferences" AfterTargets="ResolveProjectReferences">
<!-- Execute UnoRuntimeGetTargetPath for all UnoRuntimeProjectReference to get their actual output -->
<MSBuild
Projects="@(UnoRuntimeProjectReference)"
Targets="UnoRuntimeGetTargetPath"
BuildInParallel="$(BuildInParallel)"
Properties="Configuration=$(Configuration);Platform=$(Platform);TargetFramework=$(TargetFramework)"
ContinueOnError="!$(BuildingProject)">
<Output TaskParameter="TargetOutputs" ItemName="UnoRuntimeProjectReferenceOutput" />
</MSBuild>
<ItemGroup>
<!-- Add the appropriate metadata to include those files -->
<UnoRuntimeProjectReferenceOutput Update="@(UnoRuntimeProjectReferenceOutput)">
<Pack>true</Pack>
<PackagePath>uno-runtime/%(UnoRuntimeIdentifier)</PackagePath>
</UnoRuntimeProjectReferenceOutput>
<!-- Include symbols as well, if available -->
<UnoRuntimeProjectReferenceOutput
Include="@(UnoRuntimeProjectReferenceOutput->'%(rootdir)%(directory)%(filename).pdb')"
Condition="exists('%(rootdir)%(directory)%(filename).pdb')">
<Pack>true</Pack>
<PackagePath>uno-runtime/%(UnoRuntimeIdentifier)</PackagePath>
</UnoRuntimeProjectReferenceOutput>
</ItemGroup>
<ItemGroup>
<TfmSpecificPackageFile Include="@(UnoRuntimeProjectReferenceOutput)" />
</ItemGroup>
<RemoveDuplicates Inputs="@(TfmSpecificPackageFile)">
<Output TaskParameter="Filtered" ItemName="FilteredUnoRuntimeProjectReferenceOutput" />
</RemoveDuplicates>
<ItemGroup>
<TfmSpecificPackageFile Remove="@(TfmSpecificPackageFile)" />
<TfmSpecificPackageFile Include="@(FilteredUnoRuntimeProjectReferenceOutput)" />
</ItemGroup>
</Target>
<!-- Target used to determine the outputs of a project alongs with its associated UnoRuntimeIdentifier -->
<Target
Name="UnoRuntimeGetTargetPath"
DependsOnTargets="GetTargetPath"
Returns="@(UnoRuntimeTargetPathWithTargetPlatformMoniker)">
<ItemGroup>
<UnoRuntimeTargetPathWithTargetPlatformMoniker
Include="@(TargetPathWithTargetPlatformMoniker)"
UnoRuntimeIdentifier="$(UnoRuntimeIdentifier.ToLower())" />
</ItemGroup>
</Target>
<!--
Target used to warn the developer that overriden package binaries have been placed in the nuget cache.
-->
<Target Name="_UnoNotifyNugetOverride" BeforeTargets="PrepareProjectReferences">
<ItemGroup>
<!--
If System.Collections* files are present, the package may have been overriden by an Uno.UI solution
version before the introduction of this check.
-->
<_OverrideFiles Include="$(MSBuildThisFileDirectory)../../tools/System.Collections*.dll"/>
</ItemGroup>
<PropertyGroup>
<_warnForUnoOverride>false</_warnForUnoOverride>
<_warnForUnoOverride Condition="'@(_OverrideFiles)'!='' or exists('$(MSBuildThisFileDirectory)../../.packageoverride')">true</_warnForUnoOverride>
</PropertyGroup>
<Warning Condition="$(_warnForUnoOverride)"
Text="======================================"
ContinueOnError="true" />
<Warning Condition="$(_warnForUnoOverride)"
Text="The Uno.UI nuget package has been overriden and may use modified files.
Clear this package version folder in the nuget cache to return to a stable state."
ContinueOnError="true" />
<Warning Condition="$(_warnForUnoOverride)"
Text="======================================"
ContinueOnError="true" />
</Target>
<Target Name="ValidateUnoUIAndroid" BeforeTargets="BeforeBuild" Condition="'$(AndroidApplication)'!='' and '$(TargetFrameworkVersion)'!='' and '$(_AndroidApiLevel)'!=''">
<PropertyGroup Condition="'$(NETCoreAppMaximumVersion)'!='' and '$(NETCoreAppMaximumVersion)'>='6.0'">
<UnoUIMinAndroidSDKVersion>31</UnoUIMinAndroidSDKVersion>
<_CurrentTrimmedAndroidSDLVersion>$(_AndroidApiLevel)</_CurrentTrimmedAndroidSDLVersion>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.ToLowerInvariant().StartsWith('monoandroid')) or '$(ProjectTypeGuids)'=='{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}'">
<UnoUIMinAndroidSDKVersion>12.0</UnoUIMinAndroidSDKVersion>
<_CurrentTrimmedAndroidSDLVersion>$(TargetFrameworkVersion.Substring(1))</_CurrentTrimmedAndroidSDLVersion>
</PropertyGroup>
<Error Text="This version of the Android SDK ($(_CurrentTrimmedAndroidSDLVersion)) is not supported by Uno Platform. You must change the "Compile using Android version:" field in the android project property with at least version $(UnoUIMinAndroidSDKVersion)."
Condition="'$(_CurrentTrimmedAndroidSDLVersion)' < '$(UnoUIMinAndroidSDKVersion)'" />
</Target>
<!-- Validation for https://github.com/unoplatform/uno/issues/9430 and the static registrar requirement -->
<Target Name="_ValidateIOSStaticRegistrar"
BeforeTargets="BeforeBuild"
Condition="
'$(UnoDisableValidateIOSStaticRegistrar)'==''
and (
('$(TargetFramework)'=='net6.0-ios' and '$(RuntimeIdentifier)'=='iossimulator-x64')
or ('$(ProjectTypeGuids)'=='{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}' and '$(Platform)'=='iPhoneSimulator')
)
and (
'$(MtouchExtraArgs)'!=''
and !$(MtouchExtraArgs.Contains('--registrar:static'))
and !$(MtouchExtraArgs.Contains('--registrar=static'))
)
">
<Error Text="Building for the iOS Simulator requires the use of the static registrar. Make sure that `MtouchExtraArgs` contains `--registrar:static`. See https://github.com/unoplatform/uno/issues/9430 for more details." />
</Target>
</Project>