From 1f2a4a110e356808d721358ce358de4f88923795 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Tue, 3 Mar 2020 09:02:58 -0800 Subject: [PATCH] Adjust ordering of Single-file publish targets (#10740) * Adjust ordering of Single-file publish targets This change reorders certain publish targets in preparation for upcoming changes to single-file publish support in .net 5. The behavior of `dotnet publish /p:PublishSingleFile=true` is different in .net 5, compared to .net core 3, as explained in [this document](https://github.com/dotnet/designs/blob/master/accepted/single-file/design.md#build-system-interface). In some cases, the single-file bundler in HostModel library will leave certain types of files unbundled into the single-file app. These files need to be copied into the publish directory. Currently, the Single-file bundle generator after the copy step, which places files in the publish directory. However, this model is unsuitable in .net 5, because the files to be copied will only be determined after bundle-generation. Therefore, the `BundlePublishDirectory` targets now run before the copy step, along with the `ILLink` and `ReadyToRun` targets. In an upcoming change, the `GenerateBundle` task will generate outputs to trim `ResolvedFileToPublish` based on the `PublishSingleFile` settings. This change actually simplified a few other targets. --- .../targets/Microsoft.NET.Publish.targets | 64 +++++++------------ 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets index 141da1718ac9..07e79a8cafb8 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets +++ b/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets @@ -47,8 +47,6 @@ Copyright (c) .NET Foundation. All rights reserved. <_CorePublishTargets> PrepareForPublish; ComputeAndCopyFilesToPublishDirectory; - GeneratePublishDependencyFile; - BundlePublishDirectory; <_PublishNoBuildAlternativeDependsOn>$(_BeforePublishNoBuildTargets);$(_CorePublishTargets) @@ -194,11 +192,8 @@ Copyright (c) .NET Foundation. All rights reserved. - <_CurrentPublishFileWritesUnfiltered Include="@(ResolvedFileToPublish->'$(_NormalizedPublishDir)%(RelativePath)')" Condition="'$(PublishSingleFile)' != 'true'"/> - <_CurrentPublishFileWritesUnfiltered Include="@(ResolvedFileToPublish->'$(_NormalizedPublishDir)%(RelativePath)')" - Condition="'$(PublishSingleFile)' == 'true' And '%(ResolvedFileToPublish.ExcludeFromSingleFile)' == 'true'"/> + <_CurrentPublishFileWritesUnfiltered Include="@(ResolvedFileToPublish->'$(_NormalizedPublishDir)%(RelativePath)')"/> <_CurrentPublishFileWritesUnfiltered Include="$(_NormalizedPublishDir)$(AssemblyName)$(_NativeExecutableExtension)" Condition="'$(UseAppHost)' == 'true'"/> - <_CurrentPublishFileWritesUnfiltered Include="$(_NormalizedPublishDir)$(ProjectDepsFileName)" Condition="'$(GenerateDependencyFile)' == 'true' And '$(PublishSingleFile)' != 'true'"/> @@ -216,7 +211,6 @@ Copyright (c) .NET Foundation. All rights reserved. _CopyResolvedFilesToPublishPreserveNewest Copy _ResolvedFileToPublishPreserveNewest items to the publish directory - (except files that will be bundled, during PublishSingleFile). ============================================================ --> - - <_ResolvedUnbundledFileToPublishPreserveNewest - Include="@(_ResolvedFileToPublishPreserveNewest)" - Condition="'$(PublishSingleFile)' != 'true' or - '%(_ResolvedFileToPublishPreserveNewest.ExcludeFromSingleFile)'=='true'" /> - - - - - <_ResolvedUnbundledFileToPublishAlways - Include="@(_ResolvedFileToPublishAlways)" - Condition="'$(PublishSingleFile)' != 'true' or - '%(_ResolvedFileToPublishAlways.ExcludeFromSingleFile)'=='true'" /> - - - + CreateReadyToRunImages; + GeneratePublishDependencyFile; + GenerateSingleFileBundle"> @@ -942,26 +923,23 @@ Copyright (c) .NET Foundation. All rights reserved. - <_FilesToBundle Include="@(_ResolvedFileToPublishPreserveNewest)" - Condition="'%(_ResolvedFileToPublishPreserveNewest.ExcludeFromSingleFile)' != 'true'"/> - <_FilesToBundle Include="@(_ResolvedFileToPublishAlways)" - Condition="'%(_ResolvedFileToPublishAlways.ExcludeFromSingleFile)' != 'true'"/> + <_FilesToBundle Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.ExcludeFromSingleFile)' != 'true'"/> - - + + + + + + +