Make target OS/arch in Bundler and TargetInfo non-optional#126437
Make target OS/arch in Bundler and TargetInfo non-optional#126437elinor-fung merged 10 commits intomainfrom
Conversation
…ed OS/arch detection Add a new optional `runtimeIdentifier` parameter to both the `TargetInfo` and `Bundler` constructors. When provided, the runtime identifier string (e.g., "linux-x64", "win-arm64") is parsed to determine the target OS and architecture, eliminating the need for callers to implement their own RID parsing logic. Explicit `os` and `arch` parameters take precedence over RID-derived values. When neither the RID nor explicit parameters are provided, existing behavior (defaulting to the current OS/arch) is preserved. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/080a2b19-6edb-49cd-aa57-3169ae7c998c Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…iscV64 extension The NETFRAMEWORK Architecture extension already provides LoongArch64, so the #if !NETFRAMEWORK guard was incorrectly excluding it from RID parsing on .NET Framework. Add RiscV64 extension for NETFRAMEWORK parity and remove the conditional compilation from ParseRuntimeIdentifier. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/080a2b19-6edb-49cd-aa57-3169ae7c998c Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Make the OS and architecture parameters required (non-nullable) in both the TargetInfo and Bundler constructors, removing the previous approach of adding a runtimeIdentifier parameter. - TargetInfo: os and arch are now required positional parameters - Bundler: targetOS and targetArch are now required positional parameters (3rd and 4th, after hostName and outputDir) - Remove ParseRuntimeIdentifier method and HostOS fallback detection - Update all test callers to pass explicit OS/arch values - Keep #nullable enable, RiscV64/LoongArch64 extensions, Version? nullability Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/181f3158-29d6-449a-b597-e998407a7c29 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
… non-optional Restore the original parameter order (options, targetOS, targetArch) and make all three required. This avoids changing the parameter order which would be more disruptive to callers. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/181f3158-29d6-449a-b597-e998407a7c29 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…ameworkVersion non-optional - Add Binaries.CurrentOSPlatform matching the original _hostOS logic (Linux → OSX → FreeBSD → Windows fallback) - Use shared property in both BundlerConsistencyTests and SingleFileTestApp - Make targetFrameworkVersion non-optional on both TargetInfo and Bundler - All callers now pass explicit version (Environment.Version as default) Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/fb0ea73a-20ee-458f-ad6f-9362fdbdb6c7 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…getInfo Restore the ?? Environment.Version fallback for FrameworkVersion and remove the #nullable enable directive that was added. Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/111adf2b-fa15-47e9-9942-56791bd4bfe9 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
|
Tagging subscribers to this area: @agocke, @elinor-fung |
There was a problem hiding this comment.
Pull request overview
Refactors HostModel bundling APIs to require explicit target OS and architecture, removing implicit host-detection defaults and updating installer tests/utilities accordingly. Also introduces RiscV64 handling for Architecture when building under .NET Framework.
Changes:
- Make
BundlerandTargetInforequire non-optionalOSPlatformandArchitectureinputs. - Update installer test helpers and test cases to pass explicit OS/arch (via
Binaries.CurrentOSPlatformandRuntimeInformation.OSArchitecture). - Add
Architecture.RiscV64shim forNETFRAMEWORKbuilds.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/installer/managed/Microsoft.NET.HostModel/Bundle/Bundler.cs |
Updates constructor signature to require explicit target OS/arch and framework version. |
src/installer/managed/Microsoft.NET.HostModel/Bundle/TargetInfo.cs |
Removes nullable OS/arch inputs and internal host OS inference; adds RiscV64 for NETFRAMEWORK. |
src/installer/tests/TestUtils/Binaries.cs |
Adds CurrentOSPlatform helper for tests to pass explicit target OS into bundling APIs. |
src/installer/tests/TestUtils/SingleFileTestApp.cs |
Updates bundling helper to pass explicit OS/arch/version into Bundler. |
src/installer/tests/Microsoft.NET.HostModel.Tests/Bundle/BundlerConsistencyTests.cs |
Updates bundler construction in tests to provide explicit OS/arch/version. |
…getInfo.HostOS logic Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/f527b3fb-f65c-493a-bea9-97971e127876 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/a3713efd-dc6a-415b-bdde-9d5c860f6ba2 Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…e dead Illumos extension Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/f8b8e2af-d4e9-44c9-a9c7-e5c4128933ed Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
|
@elinor-fung I assume this requires some update to the SDK or were we never relying on the default behavior? |
|
We were never relying on the default behaviour. Usage in the SDK always passes these parameters: https://github.com/dotnet/sdk/blob/96683a0ad81c5694820f7824342a4ca5079bdd64/src/Tasks/Microsoft.NET.Build.Tasks/GenerateBundle.cs#L81-L89 I had that in the PR description previously, but forgot to add it back after CCA wrote over it... |
|
/ba-g the legs build analysis indicates it is waiting on all show as completed and green |
| #if NETFRAMEWORK | ||
| public static OSPlatform FreeBSD => OSPlatform.Create("FREEBSD"); | ||
| #endif | ||
| public static OSPlatform Illumos => OSPlatform.Create("ILLUMOS"); |
There was a problem hiding this comment.
Both freebsd and illumos were used once. Usage of both were removed but kept definition of one?
There was a problem hiding this comment.
@copilot Create a new PR to remove FreeBSD and the OSPlatform extension here.
Per #126437 (comment), the `FreeBSD` `OSPlatform` extension in `PlatformExtensions` was defined but never used after PR #126437 removed its only usage. This PR removes the unused `extension(OSPlatform)` block while keeping the still-used `extension(Architecture)` block for `LoongArch64`. cc @elinor-fung @am11 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…6437) This pull request refactors how the target operating system and architecture are handled in the bundling logic, making both parameters required rather than optional. It removes fallback logic that previously inferred these values from the current runtime environment, leading to more explicit and predictable behavior. **Bundler and TargetInfo API changes:** * The `Bundler` and `TargetInfo` constructors now require explicit `OSPlatform` and `Architecture` arguments, removing support for optional values and fallback to the host environment. * The static fallback logic (`HostOS`) in `TargetInfo` is removed, so the OS must always be specified. * Usage in the SDK always passes these parameters **Test and utility updates:** * Test code in `BundlerConsistencyTests` and `SingleFileTestApp` is updated to pass the required `OSPlatform` and `Architecture` values, using a new `Binaries.CurrentOSPlatform` helper and `RuntimeInformation.OSArchitecture`. * A new static property, `CurrentOSPlatform`, is added to the `Binaries` utility class to encapsulate platform detection logic for tests. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
…#126612) Per dotnet#126437 (comment), the `FreeBSD` `OSPlatform` extension in `PlatformExtensions` was defined but never used after PR dotnet#126437 removed its only usage. This PR removes the unused `extension(OSPlatform)` block while keeping the still-used `extension(Architecture)` block for `LoongArch64`. cc @elinor-fung @am11 Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: elinor-fung <47805090+elinor-fung@users.noreply.github.com>
This pull request refactors how the target operating system and architecture are handled in the bundling logic, making both parameters required rather than optional. It removes fallback logic that previously inferred these values from the current runtime environment, leading to more explicit and predictable behavior. The changes also update tests and utilities to accommodate this new requirement.
Bundler and TargetInfo API changes:
BundlerandTargetInfoconstructors now require explicitOSPlatformandArchitecturearguments, removing support for optional values and fallback to the host environment. [1] [2]HostOS) inTargetInfois removed, so the OS must always be specified.Test and utility updates:
BundlerConsistencyTestsandSingleFileTestAppis updated to pass the requiredOSPlatformandArchitecturevalues, using a newBinaries.CurrentOSPlatformhelper andRuntimeInformation.OSArchitecture. [1] [2] [3]CurrentOSPlatform, is added to theBinariesutility class to encapsulate platform detection logic for tests.Resolves #101548
cc @dotnet/appmodel @AaronRobinsonMSFT