-
Notifications
You must be signed in to change notification settings - Fork 570
/
Copy pathSkiaSharp.Build.targets
267 lines (240 loc) · 15.9 KB
/
SkiaSharp.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
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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<Project>
<Import Project="$(MSBuildThisFileDirectory)SkiaSharp.NuGet.targets" />
<PropertyGroup>
<_ManagedExeLauncher Condition=" !$(IsWindows) and Exists('/Library/Frameworks/Mono.framework/Versions/Current/bin/mono') ">/Library/Frameworks/Mono.framework/Versions/Current/bin/mono</_ManagedExeLauncher>
<_ManagedExeLauncher Condition=" !$(IsWindows) and Exists('/usr/local/bin/mono') ">/usr/local/bin/mono</_ManagedExeLauncher>
<_ManagedExeLauncher Condition=" !$(IsWindows) and Exists('/usr/bin/mono') ">/usr/bin/mono</_ManagedExeLauncher>
<_ManagedExeLauncher Condition=" !$(IsWindows) and '$(_ManagedExeLauncher)' == '' ">mono</_ManagedExeLauncher>
<_SnExePath Condition=" $(IsWindows) and '$(_SnExePath)' == '' and Exists('$(SDK40ToolsPath)sn.exe') ">$(SDK40ToolsPath)sn.exe</_SnExePath>
<_SnExePath Condition=" $(IsWindows) and '$(_SnExePath)' == '' and Exists('$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe') ">$(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe</_SnExePath>
<_SnExePath Condition=" '$(_SnExePath)' == '' ">sn</_SnExePath>
<PublicSign Condition=" '$(PublicSign)' == '' and '$(SignAssembly)' == 'true' ">true</PublicSign>
<KeyFileName Condition=" '$(KeyFileName)' == '' ">mono.snk</KeyFileName>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)..\scripts\$(KeyFileName)</AssemblyOriginatorKeyFile>
<StrongNamerKeyFile>$(AssemblyOriginatorKeyFile)</StrongNamerKeyFile>
<!--
Suppress version attribute generation in Microsoft.NET.Sdk projects to avoid build failures
when two sets of attributes are emitted.
-->
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<!--
Ignore this message:
Warning VSX1000
No Address and User has been specified in order to establish a connection to a Mac Server, so only the main
assembly was compiled for project '<project name>'. Connect to a Mac Server and try again to build the full
application.
-->
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);VSX1000</MSBuildWarningsAsMessages>
<!--
Ignore this message:
Warning MSB9004
ManifestResourceWithNoCulture item type is deprecated. Emit EmbeddedResource items instead, with metadata
WithCulture='false', Type='Resx', and optional LogicalName.
-->
<MSBuildWarningsAsMessages>$(MSBuildWarningsAsMessages);MSB9004</MSBuildWarningsAsMessages>
</PropertyGroup>
<ItemGroup Condition=" $(IsWindows) and '$(Configuration)' == 'Release' ">
<PackageReference Include="mdoc" Version="5.8.9" PrivateAssets="All" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != '' and $([MSBuild]::GetTargetFrameworkIdentifier('$(TargetFramework)')) != '.NETCoreApp'">
<Compile Include="$(MSBuildThisFileDirectory)Common\NullableAttributes.generated.cs" Visible="false" />
</ItemGroup>
<!-- HACK: Do not copy the native bootstrap files -->
<Target Name="_RemoveWasdkBootstrapDll" BeforeTargets="ResolveReferences">
<ItemGroup>
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(Filename)%(Extension)' == 'Microsoft.WindowsAppRuntime.Bootstrap.dll'" />
</ItemGroup>
</Target>
<!--
Workaround for https://github.com/dotnet/sdk/issues/11105
-->
<ItemGroup>
<SourceRoot Include="$([MSBuild]::EnsureTrailingSlash($(NuGetPackageRoot)))" Condition="'$(NuGetPackageRoot)' != ''" />
</ItemGroup>
<!--
===================================================================================================================
_CollectAssemblyVersionInfo & _GenerateAssemblyVersionInfo
Generate the assembly versioning attributes from the VERSIONS.txt file.
===================================================================================================================
-->
<Target Name="_BeforeInitializeSourceControlInformation"
DependsOnTargets="CollectAssemblyVersionInfo"
BeforeTargets="InitializeSourceControlInformation" />
<Target Name="CollectAssemblyVersionInfo"
DependsOnTargets="_CollectAssemblyVersionInfoPrepare;$(CollectAssemblyVersionInfoDependsOn)" />
<Target Name="_CollectAssemblyVersionInfoPrepare"
Condition=" '$(SkipGenerateAssemblyVersionInfo)' != 'true' ">
<PropertyGroup>
<_VersionSourceFile>$(IntermediateOutputPath)\$(AssemblyName).Version.cs</_VersionSourceFile>
<_VersionTxtFile>$(MSBuildThisFileDirectory)..\scripts\VERSIONS.txt</_VersionTxtFile>
</PropertyGroup>
<PropertyGroup>
<_VersionTxtContents>$([System.IO.File]::ReadAllText($(_VersionTxtFile)))</_VersionTxtContents>
<_VersionPackagingGroup>$(PackagingGroup.Split('.')[0])</_VersionPackagingGroup>
<_VersionAssemblyPattern>^$(_VersionPackagingGroup)\s*assembly\s*(.*)$</_VersionAssemblyPattern>
<_VersionFilePattern>^$(_VersionPackagingGroup)\s*file\s*(.*)$</_VersionFilePattern>
<_VersionNuGetPattern>^$(_VersionPackagingGroup)\s*nuget\s*(.*)$</_VersionNuGetPattern>
<_VersionMilestonePattern>^lib$(_VersionPackagingGroup)\s*milestone\s*(.*)$</_VersionMilestonePattern>
<_VersionIncrementPattern>^lib$(_VersionPackagingGroup)\s*increment\s*(.*)$</_VersionIncrementPattern>
<_VersionAssemblyMatch>$([System.Text.RegularExpressions.Regex]::Match($(_VersionTxtContents), $(_VersionAssemblyPattern), System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value.Trim())</_VersionAssemblyMatch>
<_VersionFileMatch>$([System.Text.RegularExpressions.Regex]::Match($(_VersionTxtContents), $(_VersionFilePattern), System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value.Trim())</_VersionFileMatch>
<_VersionNuGetMatch>$([System.Text.RegularExpressions.Regex]::Match($(_VersionTxtContents), $(_VersionNuGetPattern), System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value.Trim())</_VersionNuGetMatch>
<_VersionMilestoneMatch>$([System.Text.RegularExpressions.Regex]::Match($(_VersionTxtContents), $(_VersionMilestonePattern), System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value.Trim())</_VersionMilestoneMatch>
<_VersionIncrementMatch>$([System.Text.RegularExpressions.Regex]::Match($(_VersionTxtContents), $(_VersionIncrementPattern), System.Text.RegularExpressions.RegexOptions.IgnoreCase | System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value.Trim())</_VersionIncrementMatch>
</PropertyGroup>
<PropertyGroup>
<Version>$(_VersionNuGetMatch)</Version>
<Version Condition="'$(VersionSuffix)' != ''">$(Version)-$(VersionSuffix)</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<InformationalVersion Condition="'$(AssemblyVersionGitBranch)' != ''">$(InformationalVersion)+$(AssemblyVersionGitBranch.Replace('/', '-').Replace('\', '-'))</InformationalVersion>
<InformationalVersion Condition="'$(AssemblyVersionGitSha)' != ''">$(InformationalVersion).$(AssemblyVersionGitSha)</InformationalVersion>
<AssemblyVersion>$(_VersionAssemblyMatch)</AssemblyVersion>
<FileVersion>$(_VersionFileMatch)</FileVersion>
</PropertyGroup>
</Target>
<Target Name="_BeforeGenerateAssemblyInfo"
BeforeTargets="GenerateAssemblyInfo"
DependsOnTargets="_GenerateAssemblyVersionInfo" />
<Target Name="_GenerateAssemblyVersionInfo"
DependsOnTargets="CollectAssemblyVersionInfo"
Condition=" '$(SkipGenerateAssemblyVersionInfo)' != 'true' ">
<PropertyGroup>
<_VersionGeneratedContents>
internal partial class VersionConstants {
public const string AssemblyVersion = "$(AssemblyVersion)"%3B
public const string AssemblyFileVersion = "$(FileVersion)"%3B
public const string AssemblyInformationalVersion = "$(InformationalVersion)"%3B
public const string GitSha = "$(AssemblyVersionGitSha)"%3B
public const string GitBranch = "$(AssemblyVersionGitBranch)"%3B
public const int Milestone = 0$(_VersionMilestoneMatch)%3B
public const int Increment = 0$(_VersionIncrementMatch)%3B
}
</_VersionGeneratedContents>
</PropertyGroup>
<WriteLinesToFile Condition=" !Exists('$(_VersionSourceFile)') or '$([System.IO.File]::ReadAllText($(_VersionSourceFile)).Trim())' != '$(_VersionGeneratedContents.Trim())' "
File="$(_VersionSourceFile)" Lines="$(_VersionGeneratedContents)" Overwrite="true" />
<ItemGroup>
<FileWrites Include="$(_VersionSourceFile)" />
<Compile Include="$(_VersionSourceFile)" />
</ItemGroup>
</Target>
<!--
===================================================================================================================
_RemoveObsoleteItemsFromReferenceAssembly
Remove all the [Obsolete(error: true)] symbols from the reference assembly.
===================================================================================================================
-->
<ItemGroup Condition="'$(ProduceReferenceAssembly)' == 'true'">
<PackageReference Include="Mono.ApiTools.MSBuildTasks" Version="0.3.0" PrivateAssets="all" />
</ItemGroup>
<Target Name="_RemoveObsoleteItemsFromReferenceAssembly"
AfterTargets="CoreCompile"
Condition="'$(ProduceReferenceAssembly)' == 'true'">
<RemoveObsoleteSymbols Assembly="@(IntermediateRefAssembly)" Condition="Exists('@(IntermediateRefAssembly)')" />
</Target>
<!--
===================================================================================================================
_SignAssembly
Sign the assembly using sn.
===================================================================================================================
-->
<PropertyGroup Condition=" $(IsWindows) and '$(SignAssembly)' == 'true' and '$(TargetPath)' != '' and '$(BuildingInsideVisualStudio)' != 'true'">
<_SignAssemblyAfterTargets>
CoreCompile
</_SignAssemblyAfterTargets>
<_SignAssemblyAfterTargets Condition="'$(CsWinRTIncludes)' != ''">
CsWinRTReplaceForPatchedRuntime
</_SignAssemblyAfterTargets>
</PropertyGroup>
<Target Name="_SignAssembly"
AfterTargets="$(_SignAssemblyAfterTargets)"
Condition=" $(IsWindows) and '$(SignAssembly)' == 'true' and '$(TargetPath)' != '' and '$(BuildingInsideVisualStudio)' != 'true' ">
<Exec Command=""$(_SnExePath)" -q -R @(IntermediateAssembly -> '"%(Identity)"') "$(AssemblyOriginatorKeyFile)"" />
<Exec Command=""$(_SnExePath)" -q -R @(IntermediateRefAssembly -> '"%(Identity)"') "$(AssemblyOriginatorKeyFile)"" Condition="'$(ProduceReferenceAssembly)' == 'true'" />
</Target>
<!--
===================================================================================================================
_SignAssemblyVerify
Verify that the output assembly is signed correctly for release.
===================================================================================================================
-->
<PropertyGroup Condition=" $(IsWindows) and '$(SignAssembly)' == 'true' and '$(Configuration)' == 'Release' and '$(TargetPath)' != '' and '$(BuildingInsideVisualStudio)' != 'true' ">
<_SignAssemblyVerifyAfterTargets>
Build
</_SignAssemblyVerifyAfterTargets>
</PropertyGroup>
<Target Name="_SignAssemblyVerify"
AfterTargets="$(_SignAssemblyVerifyAfterTargets)"
Condition=" $(IsWindows) and '$(SignAssembly)' == 'true' and '$(Configuration)' == 'Release' and '$(TargetPath)' != '' and '$(BuildingInsideVisualStudio)' != 'true' ">
<Exec Command=""$(_SnExePath)" -vf "$(TargetPath)"" StandardOutputImportance="Normal" />
<Exec Command=""$(_SnExePath)" -vf "$(TargetRefPath)"" StandardOutputImportance="Normal" Condition="'$(ProduceReferenceAssembly)' == 'true'" />
</Target>
<!--
===================================================================================================================
_CheckSkiaSharpBuildPropsImported
Make sure that SkiaSharp.Build.props was added.
===================================================================================================================
-->
<Target Name="_CheckSkiaSharpBuildPropsImported" BeforeTargets="BeforeBuild">
<Error Text="SkiaSharp.Build.props was not imported." Condition=" '$(SkiaSharpBuildPropsImported)' != 'true' " />
</Target>
<!--
===================================================================================================================
MDocGenerateDocs
Generated the XML documentation file using mdoc.
This runs during the build phase.
===================================================================================================================
-->
<PropertyGroup Condition=" '$(SkipMDocGenerateDocs)' != 'true' and $(IsWindows) and '$(Configuration)' == 'Release' ">
<MDocGenerateDocsAfterTargets>
CoreCompile
</MDocGenerateDocsAfterTargets>
</PropertyGroup>
<Target Name="_MDocGenerateDocsDep">
<PropertyGroup>
<MDocToolPath>$(Pkgmdoc)\tools\mdoc.exe</MDocToolPath>
<MDocOutputName>$(TargetName).xml</MDocOutputName>
<MDocOutputPath>$(TargetDir)$(MDocOutputName)</MDocOutputPath>
<MDocIntermediateOutputPath>$(IntermediateOutputPath)mdoc\</MDocIntermediateOutputPath>
<_ShouldGenerateDocs Condition=" '$(MDocDocumentationDirectory)' != '' and Exists('$(MDocDocumentationDirectory)\index.xml') ">true</_ShouldGenerateDocs>
</PropertyGroup>
<ItemGroup Condition=" '$(_ShouldGenerateDocs)' == 'true' ">
<_MDocInputs Include="$(MDocDocumentationDirectory)\**\*" />
</ItemGroup>
</Target>
<Target Name="MDocGenerateDocs" Condition=" '$(SkipMDocGenerateDocs)' != 'true' and $(IsWindows) and '$(Configuration)' == 'Release' "
AfterTargets="$(MDocGenerateDocsAfterTargets)" DependsOnTargets="_MDocGenerateDocsDep"
Inputs="@(_MDocInputs)" Outputs="$(MDocIntermediateOutputPath)$(MDocOutputName)">
<MakeDir Condition=" '$(_ShouldGenerateDocs)' == 'true' "
Directories="$(MDocIntermediateOutputPath)" />
<Exec Condition=" '$(_ShouldGenerateDocs)' == 'true' "
WorkingDirectory="$(MDocIntermediateOutputPath)"
Command="$(_ManagedExeLauncher) "$(MDocToolPath)" export-msxdoc --quiet=true "$(MDocDocumentationDirectory)"" />
<Copy Condition=" Exists('$(MDocIntermediateOutputPath)$(MDocOutputName)') "
SourceFiles="$(MDocIntermediateOutputPath)$(MDocOutputName)"
DestinationFiles="$(MDocOutputPath)"
ContinueOnError="false"
Retries="0" />
<ItemGroup Condition=" '$(_ShouldGenerateDocs)' == 'true' ">
<FileWrites Include="$(MDocOutputPath)" />
<FileWrites Include="$(MDocIntermediateOutputPath)\*" />
</ItemGroup>
</Target>
<!-- HACK: the new IDE seems to not like Analyzers in AdditionalFiles -->
<Target Name="After_InjectAdditionalFiles" AfterTargets="_InjectAdditionalFiles">
<ItemGroup>
<AdditionalFiles Remove="@(AdditionalFiles)" Condition="'%(Extension)' == '.dll'" />
</ItemGroup>
</Target>
<!-- Make sure we always build with a lower version of WinRT.Runtime.dll -->
<ItemGroup>
<FrameworkReference Update="Microsoft.Windows.SDK.NET.Ref" RuntimeFrameworkVersion="10.0.19041.27" TargetingPackVersion="10.0.19041.27" />
</ItemGroup>
<Import Project="SkiaSharp.Build.Override.targets" Condition="Exists('SkiaSharp.Build.Override.targets')" />
<PropertyGroup>
<TargetFrameworks Condition="'$(TargetFrameworks)' == '' and '$(TargetFramework)' == ''">net0.0-invalid</TargetFrameworks>
</PropertyGroup>
</Project>