2017-08-21 15:34:15 +00:00
|
|
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
|
|
|
|
<PropertyGroup>
|
2017-09-25 16:57:44 +00:00
|
|
|
<_LinkTaskDirectoryRoot>$(MSBuildThisFileDirectory)../tools/</_LinkTaskDirectoryRoot>
|
|
|
|
<_LinkTaskTFM Condition=" '$(MSBuildRuntimeType)' == 'Core' ">netcoreapp2.0</_LinkTaskTFM>
|
|
|
|
<_LinkTaskTFM Condition=" '$(_LinkTaskTFM)' == '' ">net46</_LinkTaskTFM>
|
|
|
|
<_LinkTaskDirectory>$(_LinkTaskDirectoryRoot)$(_LinkTaskTFM)/</_LinkTaskDirectory>
|
|
|
|
<LinkTaskDllPath Condition=" '$(LinkTaskDllPath)' == '' ">$(_LinkTaskDirectory)ILLink.Tasks.dll</LinkTaskDllPath>
|
2017-08-21 15:34:15 +00:00
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<PropertyGroup>
|
|
|
|
<!-- LinkDuringPublish allows the linker to be disabled by passing
|
|
|
|
a property on the command-line. (/p:LinkDuringPublish=false)
|
|
|
|
-->
|
|
|
|
<LinkDuringPublish Condition=" '$(LinkDuringPublish)' == '' ">true</LinkDuringPublish>
|
|
|
|
<LinkDuringPublish Condition=" '$(LinkDuringPublish)' != 'true' ">false</LinkDuringPublish>
|
|
|
|
<ShowLinkerSizeComparison Condition=" '$(ShowLinkerSizeComparison)' == '' ">false</ShowLinkerSizeComparison>
|
2018-01-24 17:04:36 +00:00
|
|
|
<LinkerDumpDependencies Condition=" '$(LinkerDumpDependencies)' == '' ">false</LinkerDumpDependencies>
|
|
|
|
<UsedApplicationAssemblyAction Condition=" '$(UsedApplicationAssemblyAction)' == '' ">Copy</UsedApplicationAssemblyAction>
|
|
|
|
<UnusedApplicationAssemblyAction Condition=" '$(UnusedApplicationAssemblyAction)' == '' ">Delete</UnusedApplicationAssemblyAction>
|
|
|
|
<UsedPlatformAssemblyAction Condition=" '$(UsedPlatformAssemblyAction)' == '' ">Link</UsedPlatformAssemblyAction>
|
|
|
|
<UnusedPlatformAssemblyAction Condition=" '$(UnusedPlatformAssemblyAction)' == '' ">Delete</UnusedPlatformAssemblyAction>
|
|
|
|
<RootAllApplicationAssemblies Condition=" '$(RootAllApplicationAssemblies)' == '' ">true</RootAllApplicationAssemblies>
|
|
|
|
<RootAllApplicationAssemblies Condition=" '$(RootAllApplicationAssemblies)' != 'true' ">false</RootAllApplicationAssemblies>
|
2017-08-21 15:34:15 +00:00
|
|
|
</PropertyGroup>
|
2018-01-24 17:04:36 +00:00
|
|
|
|
|
|
|
<!-- This depends on LinkDuringPublish, so it needs to be imported
|
|
|
|
after the property is set. -->
|
|
|
|
<Import Project="$(MSBuildThisFileDirectory)ILLink.CrossGen.targets" />
|
|
|
|
|
2017-08-21 15:34:15 +00:00
|
|
|
<ItemGroup>
|
|
|
|
<!-- LinkerRootDescriptors (the ItemGroup) is set to contain
|
|
|
|
LinkerRootDescriptors (the Property), which allows adding
|
|
|
|
linker roots on the command-line
|
|
|
|
(/p:LinkerRootDescriptors=path/to/a.xml;path/to/b.xml;). These
|
|
|
|
are relative paths from the project to the xml file.
|
|
|
|
LinkerRootDescriptors (the ItemGroup) can also be set in the
|
|
|
|
project file, and these will be included in addition to those
|
|
|
|
specified on the command-line. -->
|
|
|
|
<LinkerRootDescriptors Include="$(LinkerRootDescriptors)" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<!-- By default, the linker will generate roots for the intermediate
|
|
|
|
assembly that root everything in the assembly. -->
|
|
|
|
<PropertyGroup>
|
|
|
|
<_IntermediateRootDescriptorName Condition=" '$(_IntermediateRootDescriptorName)' == '' ">IntermediateAssemblyRoots.xml</_IntermediateRootDescriptorName>
|
|
|
|
<_IntermediateRootDescriptorPath Condition=" '$(_IntermediateRootDescriptorPath)' == '' ">$(IntermediateOutputPath)$(_IntermediateRootDescriptorName)</_IntermediateRootDescriptorPath>
|
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<!-- The linker will place linked assemblies into an intermediate
|
|
|
|
directory, and hook into the rest of the publish pipeline to
|
|
|
|
publish the linked assemblies instead of those given as input
|
|
|
|
to the linker. -->
|
|
|
|
<PropertyGroup>
|
|
|
|
<IntermediateLinkDirName Condition=" '$(IntermediateLinkDirName)' == '' ">linked</IntermediateLinkDirName>
|
|
|
|
<IntermediateLinkDir Condition=" '$(IntermediateLinkDir)' == '' ">$(IntermediateOutputPath)$(IntermediateLinkDirName)</IntermediateLinkDir>
|
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<!-- Used to enable incremental build for the link target. -->
|
|
|
|
<PropertyGroup>
|
|
|
|
<_LinkSemaphore>$(IntermediateOutputPath)Link.semaphore</_LinkSemaphore>
|
|
|
|
</PropertyGroup>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
This target runs the linker during the publish pipeline. The
|
|
|
|
publish pipeline has a target called ComputeFilesToPublish,
|
|
|
|
which computes the ItemGroup ResolvedFileToPublish. To extend
|
|
|
|
this target, we insert a target before
|
|
|
|
ComputeFilesToPublish. Our target rewrites the relevant inputs
|
2017-09-25 16:57:44 +00:00
|
|
|
(@(IntermediateAssembly), @(ResolvedAssembliesToPublish)). This
|
|
|
|
lets ComputeFilesToPublish be ignorant of the linker, but
|
|
|
|
changes the meaning of IntermediateAssembly and
|
|
|
|
ResolvedAssembliesToPublish.
|
|
|
|
|
|
|
|
To include linked pdbs in the publish output, we also rewrite
|
|
|
|
the ComputeFilesToPublish input
|
|
|
|
@(_DebugSymbolsIntermediatePath). Note that this is a private
|
|
|
|
itemgroup, so relying on this is not ideal.
|
2017-08-21 15:34:15 +00:00
|
|
|
-->
|
|
|
|
<!-- DependsOnTargets here doesn't include the targets that compute
|
|
|
|
ResolvedAssembliesToPublish or IntermediateAssembly, because
|
|
|
|
ComputeFilesToPublish already depends on
|
|
|
|
these. BeforeTargets="ComputeFilesToPublish" ensures that
|
|
|
|
ComputeLinkedFilesToPublish will run before
|
|
|
|
ComputeFilesToPublish, but after all of its dependencies. -->
|
|
|
|
<Target Name="ComputeLinkedFilesToPublish"
|
|
|
|
BeforeTargets="ComputeFilesToPublish"
|
2017-10-19 20:04:20 +00:00
|
|
|
DependsOnTargets="_ComputeLinkedAssemblies;_FindNativeDeps"
|
2017-08-21 15:34:15 +00:00
|
|
|
Condition=" '$(LinkDuringPublish)' == 'true' ">
|
|
|
|
<!-- Rewrite ResolvedAssembliesToPublish, which is an input to
|
|
|
|
ComputeFilesToPublish. -->
|
|
|
|
<ItemGroup>
|
|
|
|
<ResolvedAssembliesToPublish Remove="@(_ManagedResolvedAssembliesToPublish)" />
|
2017-10-19 20:04:20 +00:00
|
|
|
<ResolvedAssembliesToPublish Remove="@(_NativeResolvedDepsToPublish)" />
|
|
|
|
<ResolvedAssembliesToPublish Include="@(_NativeKeptDepsToPublish)" />
|
2017-08-21 15:34:15 +00:00
|
|
|
<ResolvedAssembliesToPublish Include="@(_LinkedResolvedAssemblies)" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<!-- Rewrite IntermediateAssembly, which is an input to
|
|
|
|
ComputeFilesToPublish. -->
|
|
|
|
<ItemGroup>
|
|
|
|
<IntermediateAssembly Remove="@(IntermediateAssembly)" />
|
|
|
|
<IntermediateAssembly Include="@(_LinkedIntermediateAssembly)" />
|
|
|
|
</ItemGroup>
|
2017-09-25 16:57:44 +00:00
|
|
|
|
|
|
|
<!-- Rewrite _DebugSymbolsIntermediatePath, which is an input to
|
|
|
|
ComputeFilesToPublish. -->
|
|
|
|
<ItemGroup>
|
|
|
|
<_DebugSymbolsIntermediatePath Remove="@(_DebugSymbolsIntermediatePath)" Condition=" '$(_DebugSymbolsProduced)' == 'true' " />
|
|
|
|
<_DebugSymbolsIntermediatePath Include="@(_LinkedDebugSymbols)" Condition=" '$(_DebugSymbolsProduced)' == 'true' " />
|
|
|
|
</ItemGroup>
|
2017-08-21 15:34:15 +00:00
|
|
|
</Target>
|
|
|
|
|
2018-01-24 17:04:36 +00:00
|
|
|
<!-- The SDK has a target called ComputeRefAssembliesToPublish that
|
|
|
|
runs after ComputeFilesToPublish and rewrites
|
|
|
|
ResolvedFileToPublish to include any reference assemblies that
|
|
|
|
aren't in ResolvedAssembliesToPublish. Because
|
|
|
|
ComputeLinkedFilesToPublish changes ResolvedAssembliesToPublish
|
|
|
|
(replacing the original assemblies with linked assemblies),
|
|
|
|
this would change the behavior of
|
|
|
|
ComputeRefAssembliesToPublish, resulting in extra assemblies
|
|
|
|
being placed in the refs directory of the output. To prevent
|
|
|
|
this, we save ResolvedAssembliesToPublish before linking, and
|
|
|
|
restore it to its pre-link state before
|
|
|
|
ComputeRefAssembliesToPublish. -->
|
|
|
|
<Target Name="SaveResolvedAssembliesToPublish"
|
|
|
|
BeforeTargets="ComputeLinkedFilesToPublish">
|
|
|
|
<ItemGroup>
|
|
|
|
<PreLinkResolvedAssembliesToPublish Include="@(ResolvedAssembliesToPublish)" />
|
|
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
<Target Name="RestoreResolvedAssembliesToPublish"
|
|
|
|
BeforeTargets="ComputeRefAssembliesToPublish">
|
|
|
|
<ItemGroup>
|
|
|
|
<ResolvedAssembliesToPublish Remove="@(ResolvedAssembliesToPublish)" />
|
|
|
|
<ResolvedAssembliesToPublish Include="@(PreLinkResolvedAssembliesToPublish)" />
|
|
|
|
</ItemGroup>
|
|
|
|
</Target>
|
2017-08-21 15:34:15 +00:00
|
|
|
|
|
|
|
<!-- Print out a size comparison report for the linked
|
|
|
|
assemblies. This is disabled by default, but can be turned on
|
|
|
|
by setting $(ShowLinkerSizeComparison) to true. This runs after
|
|
|
|
the top-level link target, ComputeLinkedFilesToPublish, so it
|
|
|
|
is output even during incremental builds. -->
|
|
|
|
<UsingTask TaskName="CompareAssemblySizes" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_CompareLinkedAssemblySizes"
|
|
|
|
AfterTargets="ComputeLinkedFilesToPublish"
|
|
|
|
DependsOnTargets="_ComputeManagedAssembliesToLink;_ComputeLinkedAssemblies"
|
|
|
|
Condition=" '$(LinkDuringPublish)' == 'true' And '$(ShowLinkerSizeComparison)' == 'true' ">
|
|
|
|
<CompareAssemblySizes UnlinkedAssemblies="@(_ManagedAssembliesToLink)"
|
|
|
|
LinkedAssemblies="@(_LinkedIntermediateAssembly);@(_LinkedResolvedAssemblies)" />
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
|
2017-09-25 16:57:44 +00:00
|
|
|
<!-- Computes _LinkedResolvedAssemblies,
|
|
|
|
_LinkedIntermediateAssembly, and
|
|
|
|
_LinkedDebugSymbols. _LinkedResolvedAssemblies needs to keep
|
|
|
|
metadata from _ManagedResolvedAssembliesToPublish, since this
|
|
|
|
is used by ComputeFilesToPublish. -->
|
2017-08-21 15:34:15 +00:00
|
|
|
<Target Name="_ComputeLinkedAssemblies"
|
|
|
|
DependsOnTargets="_ComputeManagedResolvedAssembliesToPublish;ILLink">
|
|
|
|
<ItemGroup>
|
|
|
|
<__LinkedResolvedAssemblies Include="@(_ManagedResolvedAssembliesToPublish->'$(IntermediateLinkDir)/%(Filename)%(Extension)')" />
|
|
|
|
<_LinkedResolvedAssemblies Include="@(__LinkedResolvedAssemblies)" Condition="Exists('%(Identity)')" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<__LinkedIntermediateAssembly Include="@(IntermediateAssembly->'$(IntermediateLinkDir)/%(Filename)%(Extension)')" />
|
|
|
|
<_LinkedIntermediateAssembly Include="@(__LinkedIntermediateAssembly)" Condition="Exists('%(Identity)')" />
|
|
|
|
</ItemGroup>
|
2017-09-25 16:57:44 +00:00
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<__LinkedDebugSymbols Include="@(_DebugSymbolsIntermediatePath->'$(IntermediateLinkDir)/%(Filename)%(Extension)')"
|
|
|
|
Condition=" '$(_DebugSymbolsProduced)' == 'true' " />
|
|
|
|
<_LinkedDebugSymbols Include="@(__LinkedDebugSymbols)"
|
|
|
|
Condition="Exists('%(Identity)') And '$(_DebugSymbolsProduced)' == 'true' " />
|
|
|
|
</ItemGroup>
|
2017-08-21 15:34:15 +00:00
|
|
|
</Target>
|
2018-01-24 17:04:36 +00:00
|
|
|
|
|
|
|
<UsingTask TaskName="SetAssemblyActions" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_SetAssemblyActions"
|
|
|
|
DependsOnTargets="_ComputeManagedAssembliesToLink;_ComputePlatformLibraries">
|
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<_PlatformAssembliesToLink Include="@(PlatformLibraries->'%(Filename)')" />
|
|
|
|
<_PlatformAssembliesToLink Include="System.Private.CoreLib" />
|
|
|
|
<_ApplicationAssembliesToLink Include="@(_ManagedAssembliesToLink->'%(Filename)')" />
|
|
|
|
<_ApplicationAssembliesToLink Remove="@(_PlatformAssembliesToLink)" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<SetAssemblyActions AssemblyPaths="@(_ManagedAssembliesToLink)"
|
|
|
|
ApplicationAssemblyNames="@(_ApplicationAssembliesToLink)"
|
|
|
|
PlatformAssemblyNames="@(_PlatformAssembliesToLink)"
|
|
|
|
UsedApplicationAssemblyAction="$(UsedApplicationAssemblyAction)"
|
|
|
|
UnusedApplicationAssemblyAction="$(UnusedApplicationAssemblyAction)"
|
|
|
|
UsedPlatformAssemblyAction="$(UsedPlatformAssemblyAction)"
|
|
|
|
UnusedPlatformAssemblyAction="$(UnusedPlatformAssemblyAction)">
|
|
|
|
<Output TaskParameter="AssemblyPathsWithActions" ItemName="_ManagedAssembliesToLinkWithActions" />
|
|
|
|
</SetAssemblyActions>
|
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<_ManagedAssembliesToLink Remove="@(_ManagedAssembliesToLink)" />
|
|
|
|
<_ManagedAssembliesToLink Include="@(_ManagedAssembliesToLinkWithActions)" />
|
|
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
|
2017-08-21 15:34:15 +00:00
|
|
|
<!-- This calls the linker. Inputs are the managed assemblies to
|
|
|
|
link, and root specifications. The semaphore enables msbuild to
|
|
|
|
skip linking during an incremental build, when the semaphore is
|
|
|
|
up to date with respect to _ManagedAssembliesToLink. -->
|
|
|
|
<UsingTask TaskName="ILLink" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="ILLink"
|
2018-01-24 17:04:36 +00:00
|
|
|
DependsOnTargets="_ComputeManagedAssembliesToLink;_ComputeLinkerRootAssemblies;_ComputeLinkerRootDescriptors;_SetAssemblyActions"
|
2017-08-21 15:34:15 +00:00
|
|
|
Inputs="@(_ManagedAssembliesToLink);@(LinkerRootDescriptors);$(MSBuildAllProjects)"
|
|
|
|
Outputs="$(_LinkSemaphore)">
|
|
|
|
<!-- These extra arguments have been hard-coded for now, as this
|
|
|
|
is what we want to use when linking a self-contained app. In
|
|
|
|
the future we will want to generate these depending on the
|
|
|
|
scenario in which the linker is invoked. -->
|
|
|
|
<PropertyGroup>
|
2018-01-24 17:04:36 +00:00
|
|
|
<ExtraLinkerArgs Condition=" '$(ExtraLinkerArgs)' == '' ">-t -l none -b true</ExtraLinkerArgs>
|
2017-08-21 15:34:15 +00:00
|
|
|
</PropertyGroup>
|
|
|
|
<ILLink AssemblyPaths="@(_ManagedAssembliesToLink)"
|
|
|
|
RootAssemblyNames="@(LinkerRootAssemblies)"
|
|
|
|
RootDescriptorFiles="@(LinkerRootDescriptors)"
|
|
|
|
OutputDirectory="$(IntermediateLinkDir)"
|
2018-01-24 17:04:36 +00:00
|
|
|
DumpDependencies="$(LinkerDumpDependencies)"
|
2017-08-21 15:34:15 +00:00
|
|
|
ExtraArgs="$(ExtraLinkerArgs)" />
|
|
|
|
|
|
|
|
<Touch Files="$(_LinkSemaphore)" AlwaysCreate="true">
|
|
|
|
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
|
|
|
|
</Touch>
|
|
|
|
</Target>
|
|
|
|
|
2017-10-19 20:04:20 +00:00
|
|
|
<!-- FindNativeDeps scans the managed assemblies kept by the linker
|
|
|
|
to find references to native files. It outputs the found native
|
|
|
|
dependencies, and these are prevented from being published. -->
|
|
|
|
<UsingTask TaskName="FindNativeDeps" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_FindNativeDeps"
|
|
|
|
DependsOnTargets="_ComputeLinkedAssemblies">
|
|
|
|
<ItemGroup>
|
|
|
|
<_NativeResolvedDepsToPublish Include="@(ResolvedAssembliesToPublish)" />
|
|
|
|
<_NativeResolvedDepsToPublish Remove="@(_ManagedResolvedAssembliesToPublish)" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<_ManagedLinkedAssemblies Include="@(_LinkedResolvedAssemblies)" />
|
|
|
|
<_ManagedLinkedAssemblies Include="@(_LinkedIntermediateAssembly)" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<ItemGroup>
|
|
|
|
<_NativeDepsToAlwaysKeep Include="coreclr.dll;libcoreclr.dylib;libcoreclr.so" />
|
|
|
|
<_NativeDepsToAlwaysKeep Include="clrjit.dll;libclrjit.dylib;libclrjit.so" />
|
|
|
|
<_NativeDepsToAlwaysKeep Include="hostfxr.dll;libhostfxr.dylib;libhostfxr.so" />
|
|
|
|
<_NativeDepsToAlwaysKeep Include="hostpolicy.dll;libhostpolicy.dylib;libhostpolicy.so" />
|
|
|
|
</ItemGroup>
|
|
|
|
|
|
|
|
<FindNativeDeps ManagedAssemblyPaths="@(_ManagedLinkedAssemblies)"
|
|
|
|
NativeDepsPaths="@(_NativeResolvedDepsToPublish)"
|
|
|
|
NativeDepsToKeep="@(_NativeDepsToAlwaysKeep)">
|
|
|
|
<Output TaskParameter="KeptNativeDepsPaths" ItemName="_NativeKeptDepsToPublish" />
|
|
|
|
</FindNativeDeps>
|
|
|
|
|
|
|
|
</Target>
|
|
|
|
|
2017-08-21 15:34:15 +00:00
|
|
|
<!-- Computes the managed assemblies that are input to the
|
|
|
|
linker. Includes managed assemblies from
|
|
|
|
ResolvedAssembliesToPublish, and IntermediateAssembly. -->
|
|
|
|
<Target Name="_ComputeManagedAssembliesToLink"
|
|
|
|
DependsOnTargets="_ComputeManagedResolvedAssembliesToPublish">
|
|
|
|
<ItemGroup>
|
|
|
|
<_ManagedAssembliesToLink Include="@(IntermediateAssembly)" />
|
|
|
|
<_ManagedAssembliesToLink Include="@(_ManagedResolvedAssembliesToPublish)" />
|
|
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Computes the managed subset of
|
|
|
|
ResolvedAssembliesToPublish. This needs to preserve metadata,
|
|
|
|
because it is later used to compute the linked assemblies with
|
|
|
|
metadata that gets used by the rest of the publish
|
|
|
|
pipeline. This needs to run even during incremental build,
|
|
|
|
because we use the list of managed assemblies to filter the
|
|
|
|
publish output. -->
|
|
|
|
<UsingTask TaskName="ComputeManagedAssemblies" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_ComputeManagedResolvedAssembliesToPublish">
|
|
|
|
<!-- TODO: Is there a better way to get the managed assemblies
|
|
|
|
from ResolvedAssembliesToPublish? We may be able to check for
|
|
|
|
AssetType="runtime" on managed assemblies - would that give
|
|
|
|
the same set of assemblies? -->
|
|
|
|
<ComputeManagedAssemblies Assemblies="@(ResolvedAssembliesToPublish)">
|
|
|
|
<Output TaskParameter="ManagedAssemblies" ItemName="_ManagedResolvedAssembliesToPublish" />
|
|
|
|
</ComputeManagedAssemblies>
|
|
|
|
<!-- For now, hard-code System.Private.CoreLib.ni, the only .ni
|
|
|
|
file we've been encountering. This is a special case matching
|
|
|
|
how we compute the linker roots by default - we always root
|
|
|
|
System.Private.CoreLib, so we want to keep it in the publish
|
|
|
|
output and the generated deps.json file. Excluding it from
|
|
|
|
_ManagedResolvedAssembliesToPublish will prevent it from
|
|
|
|
getting filtered out of the publish output later.
|
|
|
|
|
|
|
|
In the future we may want to detect ngen assemblies and
|
|
|
|
filter them more robustly. -->
|
|
|
|
<!-- TODO: Which .ni files do we expect to be in
|
|
|
|
ResolvedAssembliesToPublish? -->
|
|
|
|
<ItemGroup>
|
|
|
|
<_ManagedResolvedAssembliesToPublish Remove="@(_ManagedResolvedAssembliesToPublish->WithMetadataValue('Filename', 'System.Private.CoreLib.ni'))" />
|
|
|
|
</ItemGroup>
|
2017-09-25 16:57:44 +00:00
|
|
|
<!-- Some of the managed dlls are satellite assemblies containing
|
|
|
|
binary resources that we don't want to link. -->
|
|
|
|
<ItemGroup>
|
|
|
|
<_ManagedResolvedAssembliesToPublish Remove="@(_ManagedResolvedAssembliesToPublish->WithMetadataValue('AssetType', 'resources'))" />
|
|
|
|
</ItemGroup>
|
2017-08-21 15:34:15 +00:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Compute the assemblies the linker should mark as roots. By
|
|
|
|
default, these are passed as "-a", but this is an
|
|
|
|
implementation detail of the link task and should not be relied
|
|
|
|
upon in general. In the future we may add other inputs to the
|
|
|
|
link task to control how these are rooted.
|
|
|
|
-->
|
|
|
|
<!-- We may want to add an additional mode in which we root only the
|
|
|
|
assembly we have built, rooting all entry points visible from
|
|
|
|
the outside of the assembly. We need to discuss whether this
|
|
|
|
even makes sense during publish, since typically libraries get
|
|
|
|
packaged via "dotnet pack", and the pack task takes input from
|
|
|
|
build, not from publish. Thus linking the library itself should
|
|
|
|
be part of the build step or pack step, OR pack could be made
|
|
|
|
to work on the publish output. -->
|
|
|
|
<Target Name="_ComputeLinkerRootAssemblies"
|
2018-01-24 17:04:36 +00:00
|
|
|
DependsOnTargets="_ComputeManagedResolvedAssembliesToPublish;_ComputePlatformLibraries;_CheckSystemPrivateCorelibEmbeddedRoots">
|
|
|
|
<!-- If RootAllApplicationAssemblies is true, roots are everything minus the framework
|
|
|
|
assemblies. This doesn't include the intermediate assembly,
|
|
|
|
because we root it separately using an xml file,
|
|
|
|
which lets us explicitly root everything.
|
|
|
|
|
|
|
|
If RootAllApplicationAssemblies is false, only intermediate assembly's Main method is rooted.
|
|
|
|
|
|
|
|
System.Private.CoreLib is rooted unless it has an embedded
|
|
|
|
xml descriptor file. -->
|
|
|
|
|
|
|
|
<ItemGroup Condition=" '$(RootAllApplicationAssemblies)' == 'true' ">
|
2017-10-19 20:04:20 +00:00
|
|
|
<_LinkerRootAssemblies Include="@(_ManagedResolvedAssembliesToPublish->'%(Filename)')" />
|
|
|
|
<_LinkerRootAssemblies Remove="@(PlatformLibraries->'%(Filename)')" />
|
2018-01-24 17:04:36 +00:00
|
|
|
<_LinkerRootAssemblies Remove="System.Private.CoreLib" Condition=" '$(_SPCHasEmbeddedRootDescriptor)' == 'true' "/>
|
2017-10-19 20:04:20 +00:00
|
|
|
<LinkerRootAssemblies Include="@(_LinkerRootAssemblies)" />
|
2017-08-21 15:34:15 +00:00
|
|
|
</ItemGroup>
|
2018-01-24 17:04:36 +00:00
|
|
|
|
|
|
|
<ItemGroup Condition=" '$(RootAllApplicationAssemblies)' == 'false' ">
|
|
|
|
<LinkerRootAssemblies Include="@(IntermediateAssembly)" />
|
|
|
|
<LinkerRootAssemblies Include="System.Private.CoreLib" Condition=" '$(_SPCHasEmbeddedRootDescriptor)' == 'false' "/>
|
|
|
|
</ItemGroup>
|
2017-08-21 15:34:15 +00:00
|
|
|
</Target>
|
|
|
|
|
2018-01-24 17:04:36 +00:00
|
|
|
<UsingTask TaskName="CheckEmbeddedRootDescriptor" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_CheckSystemPrivateCorelibEmbeddedRoots"
|
|
|
|
DependsOnTargets="_ComputeManagedAssembliesToLink">
|
|
|
|
<CheckEmbeddedRootDescriptor AssemblyPath="@(_ManagedAssembliesToLink->WithMetadataValue('Filename', 'System.Private.CoreLib'))">
|
|
|
|
<Output TaskParameter="HasEmbeddedRootDescriptor" PropertyName="_SPCHasEmbeddedRootDescriptor" />
|
|
|
|
</CheckEmbeddedRootDescriptor>
|
|
|
|
</Target>
|
2017-08-21 15:34:15 +00:00
|
|
|
|
|
|
|
<!-- Platform libraries are the managed runtime assets needed by the
|
|
|
|
"platform", currently Microsoft.NETCore.App. -->
|
|
|
|
<UsingTask TaskName="GetRuntimeLibraries" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_ComputePlatformLibraries">
|
|
|
|
<GetRuntimeLibraries AssetsFilePath="$(ProjectAssetsFile)"
|
|
|
|
TargetFramework="$(TargetFrameworkMoniker)"
|
|
|
|
RuntimeIdentifier="$(RuntimeIdentifier)"
|
|
|
|
PackageNames="$(MicrosoftNETPlatformLibrary)">
|
|
|
|
<Output TaskParameter="RuntimeLibraries" ItemName="PlatformLibraries" />
|
|
|
|
</GetRuntimeLibraries>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- This target prepares the LinkerRootDescriptors itemgroup for
|
|
|
|
input to the link task. In addition to including user-specified
|
|
|
|
LinkerRootDescriptors in the ItemGroup statically above, we
|
|
|
|
dynamically include the generated descriptor files for the
|
|
|
|
intermediate assembly. -->
|
|
|
|
<Target Name="_ComputeLinkerRootDescriptors"
|
2018-01-24 17:04:36 +00:00
|
|
|
DependsOnTargets="_GenerateIntermediateRootDescriptor"
|
|
|
|
Condition=" '$(RootAllApplicationAssemblies)' == 'true' ">
|
2017-08-21 15:34:15 +00:00
|
|
|
<ItemGroup>
|
|
|
|
<LinkerRootDescriptors Include="$(_IntermediateRootDescriptorPath)" />
|
|
|
|
</ItemGroup>
|
|
|
|
</Target>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Generates the xml root descriptor file that completely roots
|
|
|
|
the intermediate assembly. -->
|
|
|
|
<UsingTask TaskName="CreateRootDescriptorFile" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_GenerateIntermediateRootDescriptor"
|
|
|
|
Inputs="@(IntermediateAssembly)"
|
2018-01-24 17:04:36 +00:00
|
|
|
Outputs="$(_IntermediateRootDescriptorPath)"
|
|
|
|
Condition=" '$(RootAllApplicationAssemblies)' == 'true' ">
|
2017-08-21 15:34:15 +00:00
|
|
|
<CreateRootDescriptorFile AssemblyNames="@(IntermediateAssembly->'%(Filename)')"
|
|
|
|
RootDescriptorFilePath="$(_IntermediateRootDescriptorPath)" />
|
|
|
|
</Target>
|
|
|
|
|
2017-10-19 20:04:20 +00:00
|
|
|
<!-- Uses _PublishConflictPackageFiles, an input to the publish deps
|
|
|
|
file generation target, to exclude the removed managed
|
|
|
|
assemblies and native dependencies from the generated deps
|
|
|
|
file. -->
|
|
|
|
<UsingTask TaskName="ComputeRemovedAssemblies" AssemblyFile="$(LinkTaskDllPath)" />
|
|
|
|
<Target Name="_ExcludeRemovedFilesFromDepFileGeneration"
|
|
|
|
DependsOnTargets="_ComputeManagedResolvedAssembliesToPublish;_ComputeLinkedAssemblies;_FindNativeDeps;_HandlePublishFileConflicts"
|
|
|
|
BeforeTargets="GeneratePublishDependencyFile"
|
|
|
|
Condition=" '$(LinkDuringPublish)' == 'true' ">
|
|
|
|
<ComputeRemovedAssemblies InputAssemblies="@(_ManagedResolvedAssembliesToPublish)"
|
|
|
|
KeptAssemblies="@(_LinkedResolvedAssemblies)">
|
|
|
|
<Output TaskParameter="RemovedAssemblies" ItemName="_RemovedManagedAssemblies" />
|
|
|
|
</ComputeRemovedAssemblies>
|
2017-08-21 15:34:15 +00:00
|
|
|
|
2017-10-19 20:04:20 +00:00
|
|
|
<ItemGroup>
|
|
|
|
<_RemovedNativeDeps Include="@(_NativeResolvedDepsToPublish)" />
|
|
|
|
<_RemovedNativeDeps Remove="@(_NativeKeptDepsToPublish)" />
|
|
|
|
|
|
|
|
<_PublishConflictPackageFiles Include="@(_RemovedManagedAssemblies)" />
|
|
|
|
<_PublishConflictPackageFiles Include="@(_RemovedNativeDeps)" />
|
|
|
|
</ItemGroup>
|
2017-08-21 15:34:15 +00:00
|
|
|
</Target>
|
|
|
|
|
|
|
|
</Project>
|