SkiaSharp/source/SkiaSharp.Build.targets

182 строки
11 KiB
XML

<Project>
<PropertyGroup>
<_ManagedExeLauncher Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/Mono.framework/Versions/Current/bin/mono') ">/Library/Frameworks/Mono.framework/Versions/Current/bin/mono</_ManagedExeLauncher>
<_ManagedExeLauncher Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/local/bin/mono') ">/usr/local/bin/mono</_ManagedExeLauncher>
<_ManagedExeLauncher Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/bin/mono') ">/usr/bin/mono</_ManagedExeLauncher>
<_ManagedExeLauncher Condition=" '$(OS)' != 'Windows_NT' And '$(_ManagedExeLauncher)' == '' ">mono</_ManagedExeLauncher>
<PublicSign Condition=" '$(PublicSign)' == '' and '$(SignAssembly)' == 'true' and '$(OS)' != 'Windows_NT' ">true</PublicSign>
<KeyFileName Condition=" '$(KeyFileName)' == '' ">mono.snk</KeyFileName>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)..\$(KeyFileName)</AssemblyOriginatorKeyFile>
<GenerateAssemblyVersionInfo Condition=" '$(GenerateAssemblyVersionInfo)' == '' ">true</GenerateAssemblyVersionInfo>
<AssemblyVersionGitSha Condition=" '$(AssemblyVersionGitSha)' == '' ">$(GIT_SHA)</AssemblyVersionGitSha>
<AssemblyVersionGitSha Condition=" '$(AssemblyVersionGitSha)' == '' ">$(GIT_COMMIT)</AssemblyVersionGitSha>
<!--
Suppress version attribute generation in Microsoft.NET.Sdk projects to avoid build failures
when two sets of attributes are emitted.
-->
<GenerateAssemblyInformationalVersionAttribute>false</GenerateAssemblyInformationalVersionAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<!--
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>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>MSB9004</MSBuildWarningsAsMessages>
</PropertyGroup>
<PropertyGroup>
<PackagingPlatform Condition=" '$(PackagingPlatform)' == '' ">$(TargetFramework)</PackagingPlatform>
</PropertyGroup>
<ItemGroup>
<Reference Include="netstandard" />
<PackageReference Include="mdoc" Version="5.7.4.10" PrivateAssets="All" />
<PackageReference Include="Xamarin.Build.TypeRedirector" Version="0.1.2-preview" PrivateAssets="All" />
</ItemGroup>
<!--
===================================================================================================================
_GenerateAssemblyVersionInfo
Generate the assembly versioning attributes from the VERSIONS.txt file.
===================================================================================================================
-->
<Target Name="_GenerateAssemblyVersionInfo" BeforeTargets="CoreCompile" Condition=" '$(SkipGenerateAssemblyVersionInfo)' != 'true' ">
<PropertyGroup>
<_VersionSourceFile>$(IntermediateOutputPath)\$(AssemblyName).Version.cs</_VersionSourceFile>
<_VersionTxtFile>$(MSBuildThisFileDirectory)..\VERSIONS.txt</_VersionTxtFile>
</PropertyGroup>
<PropertyGroup>
<_VersionTxtContents>$([System.IO.File]::ReadAllText($(_VersionTxtFile)))</_VersionTxtContents>
<_VersionGitSha Condition=" '$(AssemblyVersionGitSha)' != '' ">-$(AssemblyVersionGitSha)</_VersionGitSha>
<_VersionPackagingGroup>$(PackagingGroup.Split('.')[0])</_VersionPackagingGroup>
<_VersionAssemblyPattern>^$(_VersionPackagingGroup)\s*assembly\s*(.*)$</_VersionAssemblyPattern>
<_VersionFilePattern>^$(_VersionPackagingGroup)\s*file\s*(.*)$</_VersionFilePattern>
<_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>
<_VersionGeneratedContents>
[assembly: System.Reflection.AssemblyVersion("$(_VersionAssemblyMatch)")]
[assembly: System.Reflection.AssemblyFileVersion("$(_VersionFileMatch)")]
[assembly: System.Reflection.AssemblyInformationalVersion("$(_VersionFileMatch)$(_VersionGitSha)")]
</_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>
<!--
===================================================================================================================
_SignAssembly
Sign the assembly using sn.
===================================================================================================================
-->
<Target Name="_SignAssembly" AfterTargets="CoreCompile" Condition=" '$(IsWindows)' != 'true' and '$(SignAssembly)' == 'true' ">
<Exec Command="sn -q -R @(IntermediateAssembly -> '&quot;%(Identity)&quot;') &quot;$(AssemblyOriginatorKeyFile)&quot;" />
</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>
<!--
===================================================================================================================
_CopyToOutputDirectory
Copy the project output into the root output folder.
===================================================================================================================
-->
<Target Name="_CopyToOutputDirectoryDep">
<ItemGroup Condition=" '$(PackagingLocation)' == '' ">
<_CopyItems Include="$(TargetPath)" Dest="nuget\lib\$(PackagingPlatform)\$(TargetFileName)" />
<_CopyItems Include="$(TargetDir)$(TargetName).xml" Dest="nuget\lib\$(PackagingPlatform)\$(TargetName).xml" Condition=" Exists('$(TargetDir)$(TargetName).xml') " />
<_CopyItems Include="$(TargetDir)$(TargetName).pdb" Dest="nuget\lib\$(PackagingPlatform)\$(TargetName).pdb" />
</ItemGroup>
<ItemGroup Condition=" '$(PackagingLocation)' != '' ">
<_CopyItems Include="$(TargetPath)" Dest="nuget\$(PackagingLocation)\$(TargetFileName)" />
<_CopyItems Include="$(TargetDir)$(TargetName).xml" Dest="nuget\$(PackagingLocation)\$(TargetName).xml" Condition=" Exists('$(TargetDir)$(TargetName).xml') " />
<_CopyItems Include="$(TargetDir)$(TargetName).pdb" Dest="nuget\$(PackagingLocation)\$(TargetName).pdb" />
</ItemGroup>
<ItemGroup>
<_CopyItems Include="@(_NoneWithTargetPath)" Dest="%(_NoneWithTargetPath.TargetPath)" />
</ItemGroup>
</Target>
<Target Name="_CopyToOutputDirectory" Condition=" '$(SkipCopyToOutputDirectory)' != 'true' and '$(TargetPath)' != '' "
AfterTargets="Build" DependsOnTargets="_CopyToOutputDirectoryDep"
Inputs="@(_CopyItems)" Outputs="@(_CopyItems -> '$(MSBuildThisFileDirectory)..\output\$(PackagingGroup)\%(Dest)')">
<Copy Condition=" '@(_CopyItems)' != '' "
SourceFiles="@(_CopyItems)"
DestinationFiles="@(_CopyItems -> '$(MSBuildThisFileDirectory)..\output\$(PackagingGroup)\%(Dest)')"
ContinueOnError="false"
Retries="0" />
</Target>
<!--
===================================================================================================================
MDocGenerateDocs
Generated the XML documentation file using mdoc.
This runs during the build phase.
===================================================================================================================
-->
<Target Name="_MDocGenerateDocsDep">
<PropertyGroup>
<MDocVersion Condition=" '%(Identity)' == 'mdoc' ">@(PackageReference -> '%(Version)')</MDocVersion>
<MDocPackagePath Condition=" '%(Name)' == 'mdoc' ">@(PackageDefinitions -> '%(ResolvedPath)')</MDocPackagePath>
<MDocPackagePath Condition=" '$(MDocPackagePath)' == '' ">$(NuGetPackageRoot)\mdoc\$(MDocVersion)</MDocPackagePath>
<MDocToolPath>$(MDocPackagePath)\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>
<_MDocInputs Include="$(MDocDocumentationDirectory)\**\*" />
</ItemGroup>
</Target>
<Target Name="MDocGenerateDocs" Condition=" '$(SkipMDocGenerateDocs)' != 'true' "
AfterTargets="CoreCompile" DependsOnTargets="_MDocGenerateDocsDep"
Inputs="@(_MDocInputs)" Outputs="$(MDocOutputPath)">
<MakeDir Directories="$(MDocIntermediateOutputPath)" />
<Exec Condition=" '$(_ShouldGenerateDocs)' == 'true' "
WorkingDirectory="$(MDocIntermediateOutputPath)"
Command="$(_ManagedExeLauncher) &quot;$(MDocToolPath)&quot; export-msxdoc --quiet=true &quot;$(MDocDocumentationDirectory)&quot;" />
<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>
</Project>