Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Running dotnet test --runtime <RID> produces warning NETSDK1179 requiring --self-contained or --no-self-contained, but these options were not supported by the test command.

Changes

  • TestCommandParser.cs: Added SelfContainedOption and NoSelfContainedOption to both VSTest and Microsoft Testing Platform command parsers
  • TestCommand.cs & MicrosoftTestingPlatformTestCommand.cs: Added mutual exclusion validation using existing CommonOptions.ValidateSelfContainedOptions()
  • Tests: Added coverage for both options individually and mutual exclusion validation

Usage

# Suppress NETSDK1179 warning with explicit self-contained behavior
dotnet test --runtime win-x86 --no-self-contained

# Or for self-contained tests
dotnet test --runtime win-x86 --self-contained

The implementation follows the same pattern as dotnet build, dotnet publish, and dotnet run. Options forward as MSBuild properties (SelfContained=true/false and _CommandLineDefinedSelfContained=true).

Original prompt

This section details on the original issue you should resolve

<issue_title>Add '--self-contained' and '--no-self-contained' options to dotnet test command</issue_title>
<issue_description>### Is your feature request related to a problem? Please describe.

Running:

dotnet test --configuration Release --runtime win-x86 --collect "XPlat Code Coverage"

Gives the following warning:

warning NETSDK1179: One of '--self-contained' or '--no-self-contained' options are required when '--runtime' is used.

However the dotnet test command does not support the --self-contained or --no-self-contained options.

Describe the solution you'd like

Add --self-contained and --no-self-contained option to dotnet test command.

Could be considered an alternate solution to #27151
</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add '--self-contained' and '--no-self-contained' options to dotnet test Add --self-contained and --no-self-contained options to dotnet test Nov 11, 2025
Copilot AI requested a review from marcpopMSFT November 11, 2025 22:10
Copilot finished work on behalf of marcpopMSFT November 11, 2025 22:10
Copy link
Member

@Youssef1313 Youssef1313 left a comment

Choose a reason for hiding this comment

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

Is the intent here to do that for MTP only? Or both MTP and VSTest?
I'm not sure if any of this will work well with VSTest. Looping @nohwnd in as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add '--self-contained' and '--no-self-contained' options to dotnet test command

3 participants