diff --git a/global.json b/global.json index f08276344578..4b9b14d91385 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "tools": { - "dotnet": "5.0.100-preview.2.20152.7", + "dotnet": "5.0.100-preview.4.20229.10", "runtimes": { "dotnet": [ "$(MicrosoftNETCoreAppRuntimePackageVersion)" diff --git a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs index 8d7bb98d39b6..97da09c9a78d 100644 --- a/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs +++ b/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs @@ -5,6 +5,8 @@ using Microsoft.NET.HostModel.Bundle; using System; using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; namespace Microsoft.NET.Build.Tasks { @@ -18,13 +20,24 @@ public class GenerateBundle : TaskBase public bool IncludeSymbols { get; set; } [Required] public string OutputDir { get; set; } + [Required] + public string TargetFrameworkVersion { get; set; } + [Required] + public string RuntimeIdentifier { get; set; } + [Required] public bool ShowDiagnosticOutput { get; set; } + [Output] + public ITaskItem[] ExcludedFiles { get; set; } + protected override void ExecuteCore() { + OSPlatform targetOS = RuntimeIdentifier.StartsWith("win") ? OSPlatform.Windows : + RuntimeIdentifier.StartsWith("osx") ? OSPlatform.OSX : OSPlatform.Linux; + 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, targetOS, new Version(TargetFrameworkVersion), ShowDiagnosticOutput); var fileSpec = new List(FilesToBundle.Length); foreach (var item in FilesToBundle) @@ -34,6 +47,12 @@ protected override void ExecuteCore() } bundler.GenerateBundle(fileSpec); + + // Certain files are excluded from the bundle, based on BundleOptions. + // For example, native files and contents files are excluded by default. + // Return the set of excluded files in ExcludedFiles, so that they can be placed in the publish directory. + + ExcludedFiles = FilesToBundle.Zip(fileSpec, (item, spec) => (spec.Excluded) ? item : null).Where(x => x != null).ToArray(); } } } 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..e9a181c3f06d 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 @@ -945,11 +945,6 @@ Copyright (c) .NET Foundation. All rights reserved. $(PublishDir)$(PublishedSingleFileName) - - - - - @@ -963,8 +958,17 @@ Copyright (c) .NET Foundation. All rights reserved. AppHostName="$(PublishedSingleFileName)" IncludeSymbols="$(IncludeSymbolsInSingleFile)" OutputDir="$(PublishDir)" - ShowDiagnosticOutput="false"/> + TargetFrameworkVersion="$(_TargetFrameworkVersionWithoutV)" + RuntimeIdentifier="$(RuntimeIdentifier)" + ShowDiagnosticOutput="false"> + + + + + + +