From 694bf08d15d40abc67e841f8df886a729865de8c Mon Sep 17 00:00:00 2001 From: Swaroop Sridhar Date: Thu, 30 Apr 2020 20:17:31 -0700 Subject: [PATCH] [release/5.0.1xx-preview4] Single-File: Pass TFM Version to the Bundler Customer Scenario A netcoreapp3.0 single file app published from .net5 SDK doesn't run. Problem The netcoreapp3.0 apphost encounters the wrong version of the bundle header when trying to extract the bundle. Solution Pass the TFM version argument to the bundler in GenrateBundle task. Risk Very Low. --- src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs | 4 +++- .../targets/Microsoft.NET.Publish.targets | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs index 8d7bb98d39b6..69547fdfa4b0 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs @@ -19,12 +19,14 @@ public class GenerateBundle : TaskBase [Required] public string OutputDir { get; set; } [Required] + public string TargetFrameworkVersion { get; set; } + [Required] public bool ShowDiagnosticOutput { get; set; } protected override void ExecuteCore() { BundleOptions options = BundleOptions.BundleAllContent | (IncludeSymbols ? BundleOptions.BundleSymbolFiles : BundleOptions.None); - var bundler = new Bundler(AppHostName, OutputDir, options, diagnosticOutput: ShowDiagnosticOutput); + var bundler = new Bundler(AppHostName, OutputDir, options, targetFrameworkVersion: new Version(TargetFrameworkVersion), diagnosticOutput: ShowDiagnosticOutput); var fileSpec = new List(FilesToBundle.Length); foreach (var item in FilesToBundle) 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 a0117a1d086d..a3267dc5575e 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 @@ -963,6 +963,7 @@ Copyright (c) .NET Foundation. All rights reserved. AppHostName="$(PublishedSingleFileName)" IncludeSymbols="$(IncludeSymbolsInSingleFile)" OutputDir="$(PublishDir)" + TargetFrameworkVersion="$(_TargetFrameworkVersionWithoutV)" ShowDiagnosticOutput="false"/>