-
Notifications
You must be signed in to change notification settings - Fork 5.4k
OS/arch optional arguments in Bundler and TargetInfo #101548
Copy link
Copy link
Open
Labels
area-HostModelMicrosoft.NET.HostModel issuesMicrosoft.NET.HostModel issues
Milestone
Description
There is a single usage of Bundle ctor in SDK and a few usages in installer tests in runtime repo. Runtime does a better job at detecting the current OS/arch when these arguments are null, while SDK is mostly out-of-sync (today OS is, and a few days ago riscv/loogarch were missing).
I'm not sure about the policy of breaking HostModel public API, but ideally we should just delete these arguments and let hostmodel take care of platform detection in one place. Alternatively, we can just cleanup the SDK code for DRY:
--- a/dotnet/sdk/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs
+++ b/dotnet/sdk/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs
@@ -34,19 +34,6 @@ public class GenerateBundle : TaskBase
protected override void ExecuteCore()
{
- OSPlatform targetOS = RuntimeIdentifier.StartsWith("win") ? OSPlatform.Windows :
- RuntimeIdentifier.StartsWith("osx") ? OSPlatform.OSX : OSPlatform.Linux;
-
- Architecture targetArch = RuntimeIdentifier.EndsWith("-x64") || RuntimeIdentifier.Contains("-x64-") ? Architecture.X64 :
- RuntimeIdentifier.EndsWith("-x86") || RuntimeIdentifier.Contains("-x86-") ? Architecture.X86 :
- RuntimeIdentifier.EndsWith("-arm64") || RuntimeIdentifier.Contains("-arm64-") ? Architecture.Arm64 :
- RuntimeIdentifier.EndsWith("-arm") || RuntimeIdentifier.Contains("-arm-") ? Architecture.Arm :
-#if !NETFRAMEWORK
- RuntimeIdentifier.EndsWith("-riscv64") || RuntimeIdentifier.Contains("-riscv64-") ? Architecture.RiscV64 :
- RuntimeIdentifier.EndsWith("-loongarch64") || RuntimeIdentifier.Contains("-loongarch64-") ? Architecture.LoongArch64 :
-#endif
- throw new ArgumentException(nameof(RuntimeIdentifier));
-
BundleOptions options = BundleOptions.None;
options |= IncludeNativeLibraries ? BundleOptions.BundleNativeBinaries : BundleOptions.None;
options |= IncludeAllContent ? BundleOptions.BundleAllContent : BundleOptions.None;
@@ -58,10 +45,8 @@ protected override void ExecuteCore()
AppHostName,
OutputDir,
options,
- targetOS,
- targetArch,
- version,
- ShowDiagnosticOutput);
+ targetFrameworkVersion: version,
+ diagnosticOutput: ShowDiagnosticOutput);
var fileSpec = new List<FileSpec>(FilesToBundle.Length);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area-HostModelMicrosoft.NET.HostModel issuesMicrosoft.NET.HostModel issues
Type
Projects
Status
No status