From 5162539009677572060cd11008279fda951bff62 Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Sat, 29 Feb 2020 18:13:37 -0800 Subject: [PATCH 1/2] 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 | 56 +++++++------------ 1 file changed, 19 insertions(+), 37 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..d7955c23b965 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; + BundlePublishDirectory"> @@ -952,10 +933,7 @@ Copyright (c) .NET Foundation. All rights reserved. Condition="'$(PublishSingleFile)' == 'true'"> - <_FilesToBundle Include="@(_ResolvedFileToPublishPreserveNewest)" - Condition="'%(_ResolvedFileToPublishPreserveNewest.ExcludeFromSingleFile)' != 'true'"/> - <_FilesToBundle Include="@(_ResolvedFileToPublishAlways)" - Condition="'%(_ResolvedFileToPublishAlways.ExcludeFromSingleFile)' != 'true'"/> + <_FilesToBundle Include="@(ResolvedFileToPublish)" Condition="'%(ResolvedFileToPublish.ExcludeFromSingleFile)' != 'true'"/> @@ -972,7 +950,13 @@ Copyright (c) .NET Foundation. All rights reserved. IncludeSymbols="$(IncludeSymbolsInSingleFile)" OutputDir="$(PublishDir)" ShowDiagnosticOutput="false"/> - + + + + + + + -