/
Xamarin.Forms.targets
237 lines (210 loc) · 10.5 KB
/
Xamarin.Forms.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_XFBuildTasksLocation Condition="'$(_XFBuildTasksLocation)' == '' AND '$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)netstandard2.0\</_XFBuildTasksLocation>
<_XFBuildTasksLocation Condition="'$(_XFBuildTasksLocation)' == ''">$(MSBuildThisFileDirectory)net46\</_XFBuildTasksLocation>
</PropertyGroup>
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.XamlGTask" AssemblyFile="$(_XFBuildTasksLocation)Xamarin.Forms.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.CssGTask" AssemblyFile="$(_XFBuildTasksLocation)Xamarin.Forms.Build.Tasks.dll" />
<UsingTask TaskName="Xamarin.Forms.Build.Tasks.XamlCTask" AssemblyFile="$(_XFBuildTasksLocation)Xamarin.Forms.Build.Tasks.dll" />
<PropertyGroup>
<SynthesizeLinkMetadata>true</SynthesizeLinkMetadata>
<EnableDefaultXamlItems Condition="'$(EnableDefaultXamlItems)'==''">True</EnableDefaultXamlItems>
<_DefaultXamlItemsEnabled>False</_DefaultXamlItemsEnabled>
<EnableDefaultCssItems Condition="'$(EnableDefaultCssItems)'==''">True</EnableDefaultCssItems>
<_DefaultCssItemsEnabled>False</_DefaultCssItemsEnabled>
<!-- The WINUI check for this only runs when there is an empty string so I just convert false to an empty string to fall in line with our other properties -->
<SkipMicrosoftUIXamlCheckTargetPlatformVersion Condition="'$(SkipMicrosoftUIXamlCheckTargetPlatformVersion)'==''">true</SkipMicrosoftUIXamlCheckTargetPlatformVersion>
<SkipMicrosoftUIXamlCheckTargetPlatformVersion Condition="'$(SkipMicrosoftUIXamlCheckTargetPlatformVersion)'=='false'"></SkipMicrosoftUIXamlCheckTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(MSBuildThisFileDirectory)Xamarin.Forms.DefaultItems.targets" Condition="'$(MSBuildSDKsPath)'!=''" />
<ItemGroup>
<ProjectCapability Include="XamarinForms" />
</ItemGroup>
<!-- Check Tasks ABI and other validations -->
<PropertyGroup>
<_XFTargetsImportedAgain Condition="'$(_XFTargetsImported)'=='True'">True</_XFTargetsImportedAgain>
<_XFTargetsImported>True</_XFTargetsImported>
<IsXBuild Condition="'$(MSBuildRuntimeType)' == ''">true</IsXBuild>
<IsXBuild Condition="'$(MSBuildRuntimeType)' != ''">false</IsXBuild>
</PropertyGroup>
<Target Name="_ValidateXFTasks" BeforeTargets="_CheckForInvalidConfigurationAndPlatform" Condition="'$(XFDisableTargetsValidation)' != 'True'">
<Error Code="XF001"
Text="Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s)."
Condition="'$(_XFTargetsImportedAgain)' == 'True'" />
</Target>
<Target Name="_ValidateMSBuild" BeforeTargets="_CheckForInvalidConfigurationAndPlatform">
<Error Code="XF003"
Text="Xamarin.Forms require msbuild. xbuild is no longer supported."
Condition="'$(IsXBuild)' == 'true'" />
</Target>
<Target Name="_ValidateNETFrameworkVersion"
BeforeTargets="_CheckForInvalidConfigurationAndPlatform"
Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' AND '$(TargetFrameworkVersion.Substring(1))' < '4.6.1' AND '$(XFDisableFrameworkVersionValidation)' != 'True'">
<Error Code="XF004"
Text="XF requires .NETFramework >= v4.6.1. You have '$(TargetFrameworkVersion)'" />
</Target>
<!-- XamlG -->
<Target
Name="UpdateDesignTimeXaml"
DependsOnTargets="XamlG"/>
<PropertyGroup>
<CoreCompileDependsOn>
XamlG;
$(CoreCompileDependsOn);
</CoreCompileDependsOn>
</PropertyGroup>
<Target
Name="_FindXamlGFiles"
DependsOnTargets="PrepareResourceNames">
<ItemGroup>
<_XamlGInputs
Include="@(EmbeddedResource)"
Condition="'%(Extension)' == '.xaml' AND '$(DefaultLanguageSourceExtension)' == '.cs' AND '%(TargetPath)' != ''" />
<_XamlGOutputs
Include="@(_XamlGInputs->'$(IntermediateOutputPath)%(TargetPath).g.cs')" />
</ItemGroup>
</Target>
<Target
Name="XamlG"
BeforeTargets="BeforeCompile"
DependsOnTargets="_FindXamlGFiles; PrepareResourceNames; AfterResolveReferences"
Inputs="@(_XamlGInputs)"
Outputs="@(_XamlGOutputs)">
<PropertyGroup>
<ReferencedAssemblies>@(ReferencePath)</ReferencedAssemblies>
</PropertyGroup>
<XamlGTask
XamlFiles="@(_XamlGInputs)"
OutputFiles="@(_XamlGOutputs)"
Language="$(Language)"
References = "$(ReferencedAssemblies)"
AssemblyName="$(AssemblyName)" />
<ItemGroup>
<FileWrites Include="@(_XamlGOutputs)" />
<Compile Include="@(_XamlGOutputs)" />
</ItemGroup>
</Target>
<!-- XamlC -->
<PropertyGroup>
<CompileDependsOn>
$(CompileDependsOn);
XamlC;
</CompileDependsOn>
</PropertyGroup>
<Target Name="XamlC" AfterTargets="AfterCompile" Inputs="$(IntermediateOutputPath)$(TargetFileName)" Outputs="$(IntermediateOutputPath)XamlC.stamp" Condition=" '$(DesignTimeBuild)' != 'True'">
<PropertyGroup>
<_XFXamlCValidateOnly>$(XFXamlCValidateOnly)</_XFXamlCValidateOnly>
<_XFXamlCValidateOnly Condition="'$(BuildingForLiveUnitTesting)' == 'True' ">True</_XFXamlCValidateOnly>
</PropertyGroup>
<XamlCTask
Assembly = "$(IntermediateOutputPath)$(TargetFileName)"
ReferencePath = "@(ReferencePath)"
OptimizeIL = "true"
DebugSymbols = "$(DebugSymbols)"
DebugType = "$(DebugType)"
ValidateOnly = "$(_XFXamlCValidateOnly)"
KeepXamlResources = "$(XFKeepXamlResources)" />
<Touch Files="$(IntermediateOutputPath)XamlC.stamp" AlwaysCreate="True" />
<ItemGroup>
<FileWrites Include="$(IntermediateOutputPath)XamlC.stamp" />
</ItemGroup>
</Target>
<!-- CssG -->
<PropertyGroup>
<CoreCompileDependsOn>
CssG;
$(CoreCompileDependsOn);
</CoreCompileDependsOn>
</PropertyGroup>
<Target Name="_FindCSSFiles" DependsOnTargets="PrepareResourceNames">
<ItemGroup>
<_CSSInputs Include="@(EmbeddedResource)" Condition="'%(Extension)' == '.css' AND '$(DefaultLanguageSourceExtension)' == '.cs' AND '%(TargetPath)' != ''" />
<_CSSOutputs Include="@(_CSSInputs->'$(IntermediateOutputPath)%(TargetPath).g.cs')" />
</ItemGroup>
</Target>
<Target Name="CssG" BeforeTargets="BeforeCompile" DependsOnTargets="_FindCSSFiles" Inputs="@(_CSSInputs)" Outputs="@(_CSSOutputs)">
<CssGTask
CSSFiles="@(_CSSInputs)"
OutputFiles="@(_CSSOutputs)"
Language = "$(Language)"
AssemblyName = "$(AssemblyName)" />
<ItemGroup>
<FileWrites Include="@(_CSSOutputs)" />
<Compile Include="@(_CSSOutputs)" />
</ItemGroup>
</Target>
<!--
Platform Specific Targets.
We can't use a framework specific targets file because it breaks shared projects i.e. /build/MonoAndroid10/Xamarin.Forms.targets
-->
<!-- MonoAndroid targets. -->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == 'MonoAndroid'">
<CoreCompileDependsOn>
IncludeProguardForAndroid;
$(CoreCompileDependsOn);
</CoreCompileDependsOn>
<PrepareForBuildDependsOn>
ValidateTargetFrameworkVersionForForms;
$(PrepareForBuildDependsOn);
</PrepareForBuildDependsOn>
</PropertyGroup>
<Target Name="IncludeProguardForAndroid" Condition="'$(XFDisableDefaultProguardConfiguration)' != 'True'">
<ItemGroup>
<ProguardConfiguration Include="$(MSBuildThisFileDirectory)MonoAndroid10\proguard.cfg" />
</ItemGroup>
</Target>
<Target Name="ValidateTargetFrameworkVersionForForms" Condition="'$(XFDisableTargetFrameworkValidation)' != 'True'">
<PropertyGroup>
<MinTargetFrameworkVersionForForms>9.0</MinTargetFrameworkVersionForForms>
<TargetFrameworkVersionWithoutV>$(TargetFrameworkVersion.TrimStart('vV'))</TargetFrameworkVersionWithoutV>
</PropertyGroup>
<Error Code="XF005" Condition="$(TargetFrameworkVersionWithoutV) < $(MinTargetFrameworkVersionForForms)"
Text="The %24(TargetFrameworkVersion) for $(ProjectName) ($(TargetFrameworkVersion)) is less than the minimum required %24(TargetFrameworkVersion) for Xamarin.Forms ($(MinTargetFrameworkVersionForForms)). You need to increase the %24(TargetFrameworkVersion) for $(ProjectName)." />
</Target>
<!-- Xamarin iOS targets -->
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS' OR '$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
<CoreCompileDependsOn>
IncludeCorrectXIOSReference;
$(CoreCompileDependsOn);
</CoreCompileDependsOn>
<PrepareForBuildDependsOn>
IncludeCorrectXIOSReference;
$(PrepareForBuildDependsOn);
</PrepareForBuildDependsOn>
</PropertyGroup>
<Target Name="IncludeCorrectXIOSReference" Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS' OR '$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">
<PropertyGroup>
<Use2017 Condition="'$(Use2017)' == '' AND '$(MSBuildRuntimeType)' == 'Mono'">$(FrameworkSDKRoot.Contains('/Versions/5'))</Use2017>
<Use2017 Condition="'$(Use2017)' == '' AND '$(MSBuildAssemblyVersion)' < '16.0'">true</Use2017>
<Use2017 Condition="'$(Use2017)' == ''">false</Use2017>
<FrameworkDll Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.iOS'">Xamarin.Forms.Platform.iOS.dll</FrameworkDll>
<FrameworkDll Condition="'$(TargetFrameworkIdentifier)' == 'Xamarin.Mac'">Xamarin.Forms.Platform.macOS.dll</FrameworkDll>
</PropertyGroup>
<ItemGroup Condition="'$(Use2017)' != 'true'">
<Reference Include="Xamarin.Forms.Platform.iOS">
<HintPath>$(MSBuildThisFileDirectory)\XCODE11\$(FrameworkDll)</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="'$(Use2017)' == 'true'">
<Reference Include="Xamarin.Forms.Platform.iOS">
<HintPath>$(MSBuildThisFileDirectory)\XCODE10\$(FrameworkDll)</HintPath>
</Reference>
</ItemGroup>
</Target>
<!-- UWP Targets-->
<Target Name="WinUICheckTargetPlatformVersion" BeforeTargets="PrepareForBuild"
Condition="'$(TargetPlatformVersion)' != '' and '$(TargetPlatformMinVersion)' != ''">
<PropertyGroup>
<MicrosoftUIXamlTargetPlatformMinCheckValue>$([System.Version]::Parse('$(TargetPlatformMinVersion)').Build)</MicrosoftUIXamlTargetPlatformMinCheckValue>
</PropertyGroup>
<Warning
Text="Xamarin.Forms recommends TargetPlatformMinVersion >= 10.0.14393.0 (current project is $(MicrosoftUIXamlTargetPlatformMinCheckValue))"
Condition="$(MicrosoftUIXamlTargetPlatformMinCheckValue) < 14393" />
<PropertyGroup>
<MicrosoftUIXamlTargetPlatformCheckValue>$([System.Version]::Parse('$(TargetPlatformVersion)').Build)</MicrosoftUIXamlTargetPlatformCheckValue>
</PropertyGroup>
<Warning
Text="Xamarin.Forms recommends TargetPlatformVersion >= 10.0.17763.0 (current project is $(MicrosoftUIXamlTargetPlatformCheckValue))"
Condition="$(MicrosoftUIXamlTargetPlatformCheckValue) < 17763" />
</Target>
</Project>