SkiaSharp/source/SkiaSharp.Build.targets

191 строка
10 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>
<!--
===================================================================================================================
_GenerateAssemblyVersionInfo
Generate the assembly versioning attributes.
===================================================================================================================
-->
<Target Name="_GenerateAssemblyVersionInfo" BeforeTargets="CoreCompile" Condition=" '$(SkipGenerateAssemblyVersionInfo)' != 'true' ">
<PropertyGroup>
<_VersionSourceFile>$(IntermediateOutputPath)\$(AssemblyName).Version.cs</_VersionSourceFile>
<_VersionTxtFile>$(MSBuildThisFileDirectory)..\VERSIONS.txt</_VersionTxtFile>
</PropertyGroup>
<_GenerateVersionFiles VersionsFile="$(_VersionTxtFile)"
OutFile="$(_VersionSourceFile)"
PackagingGroup="$(PackagingGroup)"
GitSha="$(AssemblyVersionGitSha)" />
<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="_CopyToOutputDirectory" AfterTargets="Build" Condition=" '$(SkipCopyToOutputDirectory)' != 'true' ">
<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>
<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="MDocGenerateDocs" AfterTargets="CoreCompile" Condition=" '$(SkipMDocGenerateDocs)' != 'true' ">
<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>
<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>
<!--
===================================================================================================================
_GenerateVersionFiles
Generates the assembly versioning files.
===================================================================================================================
-->
<UsingTask TaskName="_GenerateVersionFiles" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<VersionsFile ParameterType="System.String" />
<OutFile ParameterType="System.String" />
<PackagingGroup ParameterType="System.String" />
<GitSha ParameterType="System.String" />
</ParameterGroup>
<Task>
<!-- <Reference Include="" /> -->
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs"><![CDATA[
var versions = File.ReadAllText(VersionsFile);
var group = PackagingGroup;
if (PackagingGroup.Contains('.')) {
group = PackagingGroup.Split('.')[0];
}
if (!string.IsNullOrEmpty(GitSha)) {
GitSha = "-" + GitSha;
}
var assemblyMatch = Regex.Match(versions, @"^" + group + @"\s*assembly\s*(.*)$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
var fileMatch = Regex.Match(versions, @"^" + group + @"\s*file\s*(.*)$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
var contents = "using System.Reflection;\n\n";
contents += "[assembly: AssemblyVersion(\"" + assemblyMatch.Groups[1].Value.Trim() + "\")]\n";
contents += "[assembly: AssemblyFileVersion(\"" + fileMatch.Groups[1].Value.Trim() + "\")]\n";
contents += "[assembly: AssemblyInformationalVersion(\"" + fileMatch.Groups[1].Value.Trim() + GitSha + "\")]\n";
File.WriteAllText(OutFile, contents);
]]></Code>
</Task>
</UsingTask>
</Project>