200 строки
8.5 KiB
XML
200 строки
8.5 KiB
XML
<Project>
|
|
|
|
<!--
|
|
======================================================================
|
|
This target ensures that the input is valid.
|
|
======================================================================
|
|
-->
|
|
<Target Name="_ILRepackParameters">
|
|
|
|
<PropertyGroup>
|
|
<!-- The primary assmbly is used for the attributes, TFM, version, and filenames -->
|
|
<ILRepackPrimaryAssembly Condition="'$(ILRepackPrimaryAssembly)' == ''">$(OutputPath)$(AssemblyName).dll</ILRepackPrimaryAssembly>
|
|
<!-- The output file location, all satellite assemblies will be named this and in this folder -->
|
|
<ILRepackOutputAssembly Condition="'$(ILRepackOutputAssembly)' == ''">$(OutputPath)ILRepacked\$(AssemblyName).dll</ILRepackOutputAssembly>
|
|
<!-- The output folder for all the related files -->
|
|
<ILRepackOutputPath>$([System.IO.Path]::GetDirectoryName($(ILRepackOutputAssembly)))</ILRepackOutputPath>
|
|
</PropertyGroup>
|
|
|
|
</Target>
|
|
|
|
<!--
|
|
======================================================================
|
|
This target takes all the imput files and and collects and/or
|
|
calculate various related inputs as well as all the outputs.
|
|
======================================================================
|
|
-->
|
|
<Target Name="_ILRepackProperties">
|
|
|
|
<PropertyGroup>
|
|
<!-- NOTE: Strong naming is only supported by the .NET Full Framework and/or on Windows -->
|
|
<_ILRepackPerformRepack Condition="'$(OS)' == 'Windows_NT'">true</_ILRepackPerformRepack>
|
|
<!-- This is a binary from https://github.com/mattleibow/il-repack which has support for portable PDB -->
|
|
<ILRepackPath Condition="'$(ILRepackPath)' == ''">$(MSBuildThisFileDirectory)ILRepack.exe</ILRepackPath>
|
|
</PropertyGroup>
|
|
|
|
<!-- Determine the primary and output assembly names/paths -->
|
|
<ItemGroup>
|
|
<_ILRepackPrimaryAssembly Include="$(ILRepackPrimaryAssembly)" />
|
|
<_ILRepackInputAssemblies Include="@(ILRepackInputAssemblies)" />
|
|
<_ILRepackOutputAssembly Include="$(ILRepackOutputAssembly)" />
|
|
</ItemGroup>
|
|
<ItemGroup>
|
|
<_ILRepackAllAssemblies Include="@(_ILRepackPrimaryAssembly->'%(RootDir)%(Directory)%(Filename)%(Extension)')" />
|
|
<_ILRepackAllAssemblies Include="@(_ILRepackInputAssemblies->'%(RootDir)%(Directory)%(Filename)%(Extension)')" />
|
|
<_ILRepackAllAssembliesPdb Include="@(_ILRepackAllAssemblies->'%(RootDir)%(Directory)%(Filename).pdb')" />
|
|
<_ILRepackOutputAssemblyPdb Include="@(_ILRepackOutputAssembly->'%(RootDir)%(Directory)%(Filename).pdb')" />
|
|
</ItemGroup>
|
|
|
|
<!-- Locate the .NET Standard assembly -->
|
|
<ItemGroup>
|
|
<_NetstandardPath Include="@(ReferencePath->'%(RootDir)%(Directory)')" Condition="'%(FileName)%(Extension)' == 'netstandard.dll'" />
|
|
</ItemGroup>
|
|
<PropertyGroup>
|
|
<_NetstandardDir>@(_NetstandardPath)</_NetstandardDir>
|
|
</PropertyGroup>
|
|
|
|
<!-- Generate the ILRepack args that are common for all assemblies -->
|
|
<PropertyGroup>
|
|
<_ILRepackCommonArgs>/ver:$(FileVersion) /internalize /keyfile:"$(StrongNamerKeyFile)" /lib:"$(_NetstandardDir.TrimEnd('\'))"</_ILRepackCommonArgs>
|
|
</PropertyGroup>
|
|
|
|
<!-- Collect all the satallite assemblies and "group" into language folders -->
|
|
<CreateItem Include="@(_ILRepackAllAssemblies->'%(RootDir)%(Directory)*\%(Filename).resources.dll')">
|
|
<Output TaskParameter="Include" ItemName="_ILRepackSatellite" />
|
|
</CreateItem>
|
|
<ItemGroup>
|
|
<_ILRepackSatelliteLanguage Include="@(_ILRepackSatellite->Distinct())" />
|
|
<_ILRepackAllSatellites Include="@(_ILRepackSatellite)" />
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
<!--
|
|
======================================================================
|
|
This target generates all the merged satellite assemblies.
|
|
======================================================================
|
|
-->
|
|
<Target Name="_ILRepackSatelliteAssemblies"
|
|
Outputs="%(_ILRepackSatelliteLanguage.Identity)"
|
|
DependsOnTargets="_ILRepackProperties"
|
|
Condition="@(_ILRepackSatellite->Count()) > 0">
|
|
|
|
<!-- Calculate the output paths -->
|
|
<PropertyGroup>
|
|
<_ILRepackLanguage>%(_ILRepackSatelliteLanguage.RecursiveDir)</_ILRepackLanguage>
|
|
<_ILRepackLanguageOutput>@(_ILRepackOutputAssembly->'%(RootDir)%(Directory)$(_ILRepackLanguage)%(Filename).resources.dll')</_ILRepackLanguageOutput>
|
|
<_ILRepackLanguageOutputDir>@(_ILRepackOutputAssembly->'%(RootDir)%(Directory)$(_ILRepackLanguage)')</_ILRepackLanguageOutputDir>
|
|
</PropertyGroup>
|
|
|
|
<!-- Collect all the assemblies for this language -->
|
|
<ItemGroup>
|
|
<_ILRepackSatelliteForLanguage Remove="@(_ILRepackSatelliteForLanguage)" />
|
|
<_ILRepackSatelliteForLanguage Include="@(_ILRepackAllSatellites)" Condition="'%(_ILRepackAllSatellites.RecursiveDir)' == '$(_ILRepackLanguage)'" />
|
|
</ItemGroup>
|
|
|
|
<!-- Merge the assemblies, if we can -->
|
|
<Exec
|
|
Command=""$(ILRepackPath)" /out:"$(_ILRepackLanguageOutput)" @(_ILRepackSatelliteForLanguage->'"%(Identity)"', ' ') $(_ILRepackCommonArgs)"
|
|
WorkingDirectory="$(TargetDir)"
|
|
Condition="'$(_ILRepackPerformRepack)' == 'true'" />
|
|
<!-- Otherwise, just copy to the output foler -->
|
|
<Copy
|
|
SourceFiles="@(_ILRepackSatelliteForLanguage)"
|
|
DestinationFolder="$(_ILRepackLanguageOutputDir)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'$(_ILRepackPerformRepack)' != 'true'">
|
|
<Output TaskParameter="CopiedFiles" ItemName="_ILRepackCopiedFiles" />
|
|
</Copy>
|
|
|
|
<ItemGroup>
|
|
<_ILRepackCopiedFiles Include="$(_ILRepackLanguageOutput)" />
|
|
<FileWrites Include="@(_ILRepackCopiedFiles)" />
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
<!--
|
|
======================================================================
|
|
This target generates the merged primary assembly.
|
|
======================================================================
|
|
-->
|
|
<Target Name="_ILRepackAssemblies"
|
|
DependsOnTargets="_ILRepackProperties">
|
|
|
|
<!-- Merge the assemblies, if we can -->
|
|
<Exec
|
|
Command=""$(ILRepackPath)" /out:"@(_ILRepackOutputAssembly->'%(RootDir)%(Directory)%(Filename)%(Extension)')" @(_ILRepackAllAssemblies->'"%(Identity)"', ' ') $(_ILRepackCommonArgs)"
|
|
WorkingDirectory="$(TargetDir)"
|
|
Condition="'$(_ILRepackPerformRepack)' == 'true'" />
|
|
|
|
<!-- Otherwise, just copy to the output foler -->
|
|
<Copy
|
|
SourceFiles="@(_ILRepackAllAssemblies);@(_ILRepackAllAssembliesPdb)"
|
|
DestinationFolder="$(ILRepackOutputPath)"
|
|
SkipUnchangedFiles="true"
|
|
Condition="'$(_ILRepackPerformRepack)' != 'true'">
|
|
<Output TaskParameter="CopiedFiles" ItemName="_ILRepackCopiedFiles" />
|
|
</Copy>
|
|
|
|
<Touch Files="$(IntermediateOutputPath)ILRepacker.stamp" AlwaysCreate="True" />
|
|
<ItemGroup>
|
|
<_ILRepackCopiedFiles Include="$(_ILRepackOutputAssembly);@(_ILRepackOutputAssemblyPdb)" />
|
|
<FileWrites Include="$(IntermediateOutputPath)ILRepacker.stamp;@(_ILRepackCopiedFiles)" />
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
<!--
|
|
======================================================================
|
|
This target initiates the merge of both the primary and
|
|
satellite assemblies.
|
|
======================================================================
|
|
-->
|
|
<Target Name="_ILRepack"
|
|
Inputs="$(MSBuildAllProjects);@(ILRepackPrimaryAssembly);@(ILRepackInputAssemblies)"
|
|
Outputs="$(IntermediateOutputPath)ILRepacker.stamp"
|
|
DependsOnTargets="_ILRepackAssemblies;_ILRepackSatelliteAssemblies">
|
|
|
|
<ItemGroup>
|
|
<ILRepackOutput Include="$(ILRepackOutputPath)\**" />
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
<!--
|
|
======================================================================
|
|
This target is meant to be replaced by a project-specific target
|
|
and will run before any merging takes place.
|
|
======================================================================
|
|
-->
|
|
<Target Name="BeforeILRepack" />
|
|
|
|
<!--
|
|
======================================================================
|
|
This target is meant to be replaced by a project-specific target
|
|
and will run after all merging has taken place.
|
|
======================================================================
|
|
-->
|
|
<Target Name="AfterILRepack" />
|
|
|
|
<!--
|
|
======================================================================
|
|
This target is the main entrypoint for doing assembly merges.
|
|
======================================================================
|
|
-->
|
|
<Target Name="ILRepack"
|
|
DependsOnTargets="BeforeILRepack;_ILRepackParameters;_ILRepack;AfterILRepack" />
|
|
|
|
<!--
|
|
======================================================================
|
|
This target can be used to automatically enable merging as part of
|
|
the build process using the `$(ILRepackBeforePack)` property.
|
|
======================================================================
|
|
-->
|
|
<Target Name="_ILRepackBeforeNuGetPack"
|
|
AfterTargets="Build"
|
|
Condition="'$(ILRepackBeforePack)' == 'True'"
|
|
DependsOnTargets="ILRepack" />
|
|
|
|
</Project> |