Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Plan: Add --self-contained and --no-self-contained options to dotnet test command

Implementation Checklist:

  • Resolve merge conflict with main branch
  • Add SelfContainedOption and NoSelfContainedOption to MicrosoftTestingPlatformOptions.cs (MTP only)
  • Add options to ConfigureTestingPlatformCommand only (not VSTest)
  • Validation in MicrosoftTestingPlatformTestCommand.cs only (not VSTest)
  • Build and verify the changes work

Changes Made (Per Review Feedback):

Based on reviewer feedback that these options should be MTP-only, the implementation was updated:

  1. MicrosoftTestingPlatformOptions.cs:

    • Added SelfContainedOption and NoSelfContainedOption properties
  2. TestCommandDefinition.cs:

    • Removed SelfContainedOption and NoSelfContainedOption properties
    • Removed options from ConfigureVSTestCommand()
    • Updated ConfigureTestingPlatformCommand() to use MicrosoftTestingPlatformOptions.SelfContainedOption
  3. TestCommand.cs (VSTest):

    • Removed validation for self-contained options (VSTest doesn't support these)
  4. MicrosoftTestingPlatformTestCommand.cs:

    • Updated validation to reference MicrosoftTestingPlatformOptions.SelfContainedOption
  5. Tests:

    • Removed VSTest-specific tests for these options since they're now MTP-only

Verification:

✅ Build succeeds in Debug configuration
✅ Options appear in dotnet test --help only when using MTP mode (via global.json)
✅ Options do NOT appear in VSTest mode

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.

…ommand

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
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.

@marcpopMSFT
Copy link
Member

@Youssef1313 any test type that supports exe tests should have these. I don't know if there is a way to filter the CLI like that so probably it should error if you use one of those flags with a test type that doesn't support that app type. The argument from Chet was that anything that does a build and builds an app should have these flag for consistency.

@Youssef1313
Copy link
Member

In that case it is MTP only and is known at CLI level

@nohwnd
Copy link
Member

nohwnd commented Nov 14, 2025

I don't see this issue happening on net10.0 anymore, also noted by marc here: #27151 (comment)

Red because I don't have x86 runtime so tests cannot run, but no warning before:

image

Same for MTP, no warning:

image

@marcpopMSFT
Copy link
Member

@copilot can you resolve the merge conflict

@marcpopMSFT
Copy link
Member

@nohwnd for clarity, in triage we determined the other issue wasn't happening anymore but also Chet indicated that we should be consistent across our commands. Hence this PR (ie this is different than the intent of the original issue). Let me know if ya'll don't want these flags in dotnet test or there's a way to limit them to just MTP that I can tell copilot to do.

- TestCommandParser was refactored in main branch with options moved to TestCommandDefinition
- Added SelfContainedOption and NoSelfContainedOption to TestCommandDefinition
- Added options to both ConfigureVSTestCommand and ConfigureTestingPlatformCommand
- Updated all references from TestCommandParser to TestCommandDefinition throughout codebase
- Fixed validation in TestCommand and MicrosoftTestingPlatformTestCommand to use TestCommandDefinition

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot AI force-pushed the copilot/add-self-contained-options-dotnet-test branch from c6fa7f3 to 07ef2e5 Compare November 20, 2025 20:16
Copy link
Contributor Author

Copilot AI commented Nov 20, 2025

@copilot can you resolve the merge conflict

Merge conflict resolved in commit 07ef2e5. The main branch had refactored TestCommandParser by moving all option definitions to a new TestCommandDefinition.cs file. I've adapted the changes to work with this new structure.

Copilot finished work on behalf of marcpopMSFT November 20, 2025 20:18
Comment on lines 317 to 318
command.Options.Add(SelfContainedOption);
command.Options.Add(NoSelfContainedOption);
Copy link
Member

Choose a reason for hiding this comment

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

These two lines apply to VSTest, which I think should be reverted.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit e8687e6. The self-contained options are now MTP-only.

Comment on lines 272 to 273
command.Options.Add(SelfContainedOption);
command.Options.Add(NoSelfContainedOption);
Copy link
Member

Choose a reason for hiding this comment

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

These two lines apply to MTP. In that case, I would move SelfContainedOption and NoSelfContainedOption to MicrosoftTestingPlatformOptions instead of this class.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot please move these options to MicrosoftTestingPlatformOptions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved to MicrosoftTestingPlatformOptions in commit e8687e6.

Comment on lines 26 to 28
CommonOptions.ValidateSelfContainedOptions(
parseResult.HasOption(TestCommandDefinition.SelfContainedOption),
parseResult.HasOption(TestCommandDefinition.NoSelfContainedOption));
Copy link
Member

Choose a reason for hiding this comment

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

This is VSTest-specific, and should be reverted I think.

Copy link
Member

Choose a reason for hiding this comment

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

@copilot please revert

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in commit e8687e6. Validation is now only in MicrosoftTestingPlatformTestCommand.cs.

Per review feedback:
- Moved SelfContainedOption and NoSelfContainedOption to MicrosoftTestingPlatformOptions
- Removed these options from ConfigureVSTestCommand (VSTest)
- Removed validation from TestCommand.cs (VSTest)
- Updated MicrosoftTestingPlatformTestCommand.cs to reference MicrosoftTestingPlatformOptions
- Removed VSTest-specific tests for these options since they're now MTP-only

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot finished work on behalf of marcpopMSFT November 25, 2025 18:26
Copilot finished work on behalf of marcpopMSFT November 25, 2025 18:34
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

4 participants