Skip to content

Add support for --os option to the restore command #49166

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented May 27, 2025

In .NET 6, we added support for implied/partial RIDs as well as flags for specifying the OS portions of a RID. With this PR, the --os option is now supported in the dotnet restore command, providing the same functionality as it does in other commands like dotnet build.

This change allows users to specify the target operating system when performing RID-specific restores, with any missing RID portions being inferred from the current SDK execution context. For example, running dotnet restore --os linux on a Windows x64 machine will result in a restore targeting the linux-x64 RID.

The implementation:

  1. Adds the existing OperatingSystemOption to the restore command options
  2. Updates the documentation to include information about the new option

This change ensures consistency across the dotnet CLI by making the --os option available in the restore command, similar to the existing --arch option.

Fixes #24251.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 8xbvsblobprodcus382.vsblob.vsassets.io
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)
  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/sdk/sdk/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/sdk/sdk/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/sdk/sdk/artifacts/toolset/10.0.0-beta.25265.101.txt (dns block)
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)
  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)
  • mfjvsblobprodcus373.vsblob.vsassets.io
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)
  • s4uvsblobprodcus326.vsblob.vsassets.io
    • Triggering command: dotnet build src/Cli/dotnet/dotnet.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Add support for --os the restore command Add support for --os option to the restore command May 27, 2025
@Copilot Copilot AI requested a review from marcpopMSFT May 27, 2025 20:48
Copilot finished work on behalf of marcpopMSFT May 27, 2025 20:48
@marcpopMSFT
Copy link
Member

@copilot can you add a test for dotnet restore into GivenThatIWantToRestoreApp.cs that covers -r, --os and -a?

Copy link
Contributor Author

Copilot AI commented May 27, 2025

@copilot can you add a test for dotnet restore into GivenThatIWantToRestoreApp.cs that covers -r, --os and -a?

I've added a test for dotnet restore with the requested options. The new test ItRestoresWithRidSpecificOptions in GivenThatIWantToRestoreApp.cs covers all the requested scenarios: -r/--runtime, --os, and -a/--arch options, including a case that combines both --os and -a options. The test verifies that the restore command successfully runs with these options and creates the expected assets file. The changes are in commit 501a7f1.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 8xbvsblobprodcus382.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)
  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)
  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)
  • mfjvsblobprodcus373.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)
  • s4uvsblobprodcus326.vsblob.vsassets.io
    • Triggering command: dotnet build test/dotnet.Tests/dotnet.Tests.csproj (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of marcpopMSFT May 27, 2025 22:02
@marcpopMSFT
Copy link
Member

@copilot it appears three verify completion tests are failing as they don't know about the new --os flag. Can you fix the test baselines? Here's the test failure output to help.

[xUnit.net 00:00:11.37] Received: DotnetCliSnapshotTests.VerifyCompletions.received.sh
[xUnit.net 00:00:11.37] Verified: DotnetCliSnapshotTests.VerifyCompletions.verified.sh
[xUnit.net 00:00:11.37] Compare Result:
[xUnit.net 00:00:11.37] 1308
[xUnit.net 00:00:11.37] - opts="--disable-build-servers --source --packages --use-current-runtime --disable-parallel --configfile --no-http-cache --ignore-failed-sources --force --runtime --no-dependencies --verbosity --interactive --artifacts-path --use-lock-file --locked-mode --lock-file-path --force-evaluate --arch --help"
[xUnit.net 00:00:11.37] + opts="--disable-build-servers --source --packages --use-current-runtime --disable-parallel --configfile --no-http-cache --ignore-failed-sources --force --runtime --no-dependencies --verbosity --interactive --artifacts-path --use-lock-file --locked-mode --lock-file-path --force-evaluate --arch --os --help"
[xUnit.net 00:00:11.37] 1310

[xUnit.net 00:00:11.38] Received: DotnetCliSnapshotTests.VerifyCompletions.received.ps1
[xUnit.net 00:00:11.38] Verified: DotnetCliSnapshotTests.VerifyCompletions.verified.ps1
[xUnit.net 00:00:11.38] Compare Result:
[xUnit.net 00:00:11.38] 0785 [CompletionResult]::new('--arch', '-a', [CompletionResultType]::ParameterName, "The target architecture.")
[xUnit.net 00:00:11.38] + [CompletionResult]::new('--os', '--os', [CompletionResultType]::ParameterName, "The target operating system.")
[xUnit.net 00:00:11.38] 0787 [CompletionResult]::new('--help', '--help', [CompletionResultType]::ParameterName, "Show command line help.")

[xUnit.net 00:00:11.42] Received: DotnetCliSnapshotTests.VerifyCompletions.received.zsh
[xUnit.net 00:00:11.42] Verified: DotnetCliSnapshotTests.VerifyCompletions.verified.zsh
[xUnit.net 00:00:11.42] Compare Result:
[xUnit.net 00:00:11.42] 0813 '-a=[The target architecture.]:ARCH: '
[xUnit.net 00:00:11.42] + '--os=[The target operating system.]:OS: '
[xUnit.net 00:00:11.42] 0815 '--help[Show command line help.]' \

Copy link
Contributor Author

Copilot AI commented Jun 6, 2025

@copilot it appears three verify completion tests are failing as they don't know about the new --os flag. Can you fix the test baselines? Here's the test failure output to help.

[xUnit.net 00:00...

I've fixed the completion test baselines for the three failing shell formats by adding the --os option to the expected completion outputs. The changes include:

  • bash: Added --os to the options list in DotnetCliSnapshotTests.VerifyCompletions.verified.sh
  • PowerShell: Added completion result for --os in DotnetCliSnapshotTests.VerifyCompletions.verified.ps1
  • zsh: Added --os completion entry in DotnetCliSnapshotTests.VerifyCompletions.verified.zsh

These updates match exactly what the test failure output indicated was missing. The changes are in commit 5e5908f.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 8xbvsblobprodcus382.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)
  • bcnvsblobprodcus378.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)
  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)
    • Triggering command: /home/REDACTED/work/sdk/sdk/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:normal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/sdk/sdk/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/sdk/sdk/artifacts/toolset/10.0.0-beta.25265.101.txt (dns block)
  • i1qvsblobprodcus353.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)
  • l49vsblobprodcus358.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)
  • mfjvsblobprodcus373.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)
  • s4uvsblobprodcus326.vsblob.vsassets.io
    • Triggering command: dotnet test test/dotnet.Tests/dotnet.Tests.csproj --filter DotnetCliSnapshotTests.VerifyCompletions --verbosity normal (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of marcpopMSFT June 6, 2025 19:45
@marcpopMSFT
Copy link
Member

@copilot The files under documentation/manpages/sdk are generated based on our documentation and should not be manually edited. Can you revert the changes to that file? Can you also update the copilot-instructions.md file to help ensure those files are not edited by any copilots in the future?

Copy link
Contributor Author

Copilot AI commented Jun 6, 2025

@copilot The files under documentation/manpages/sdk are generated based on our documentation and should not be manually edited. Can you revert the changes to that file? Can you also update the copilot...

I've reverted the changes to documentation/manpages/sdk/dotnet-restore.1 as requested since those files are generated. I've also updated .github/copilot-instructions.md to include guidance that files under documentation/manpages/sdk should not be manually edited. The changes are in commit 77c887a.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • c78vsblobprodcus322.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/sdk/sdk/.dotnet/dotnet msbuild /m /nologo /clp:Summary /v:minimal /nr:true /warnaserror /p:TreatWarningsAsErrors=true /p:ContinuousIntegrationBuild=false /home/REDACTED/work/sdk/sdk/artifacts/toolset/restore.proj /t:__WriteToolsetLocation /clp:ErrorsOnly;NoSummary /p:__ToolsetLocationOutputFile=/home/REDACTED/work/sdk/sdk/artifacts/toolset/10.0.0-beta.25265.101.txt (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot finished work on behalf of marcpopMSFT June 6, 2025 20:59
@marcpopMSFT marcpopMSFT marked this pull request as ready for review June 6, 2025 21:03
@Copilot Copilot AI review requested due to automatic review settings June 6, 2025 21:03
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for the --os option to the dotnet restore command, aligning its behavior with other commands like dotnet build.

  • Adds the new --os option to CLI completions across zsh, PowerShell, and bash snapshot tests.
  • Introduces a RID-specific test verifying support for --os along with other related options.
  • Updates the restore command parser to include the new OperatingSystemOption.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/dotnet.Tests/CompletionTests/snapshots/zsh/DotnetCliSnapshotTests.VerifyCompletions.verified.zsh Added --os completion entry to the snapshot.
test/dotnet.Tests/CompletionTests/snapshots/pwsh/DotnetCliSnapshotTests.VerifyCompletions.verified.ps1 Added --os completion entry to the snapshot.
test/dotnet.Tests/CompletionTests/snapshots/bash/DotnetCliSnapshotTests.VerifyCompletions.verified.sh Added --os option to the list of completion options.
test/dotnet.Tests/CommandTests/Restore/GivenThatIWantToRestoreApp.cs Introduced tests for RID-specific restore options, including --os.
src/Cli/dotnet/Commands/Restore/RestoreCommandParser.cs Updated to add the OperatingSystemOption to the restore command.
.github/copilot-instructions.md Updated documentation instructions regarding generated files.

@marcpopMSFT
Copy link
Member

The watch tests are failing which is a known issue. #49150 is tracking the fix. We should remerge once that is checked in so we can rerun the tests.

Copilot AI and others added 3 commits June 10, 2025 16:08
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for --os the restore command
2 participants