Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 7, 2025

  • Add dotnet new slnf command to create solution filter files
    • Create template structure in template_feed for slnf
    • Add template.json configuration for slnf template
    • Add template content with SolutionFilter1.slnf
    • Add dotnetcli.host.json to customize ParentSolution to use --parent-solution and -s
    • Add tests for --parent-solution and -s parameters
  • Update dotnet sln command to support slnf files
    • Modify SolutionAddCommand to support adding projects to slnf files
    • Modify SolutionRemoveCommand to support removing projects from slnf files
    • SolutionListCommand already supports listing projects in slnf files
    • Add validation to ensure projects added to slnf are in parent solution
    • Add SlnfFileHelper to save slnf files in JSON format
    • Fix null reference issues in path handling
    • Normalize path separators for cross-platform compatibility
  • Add tests for new functionality
    • Add test asset TestAppWithSlnfFiles
    • Tests for dotnet sln add with slnf files
    • Tests for dotnet sln remove with slnf files
    • Tests for --in-root option with slnf files (should error)
    • All slnf tests passing (6 tests)
    • Tests for dotnet new slnf with --parent-solution and -s (3 tests)
    • All common template tests passing (31 tests)
    • Updated all tab completion test baselines
Original prompt

This section details on the original issue you should resolve

<issue_title>Creating and editing slnf files from cli</issue_title>
<issue_description>Slnf files are very useful when working on a large repository. Current creating slnf is supported from visual studio. Though it is possible to use it with cli and vs code. So why not just support creating slnf files from .net cli? Just like sln file. dotnet new slnf ....args</issue_description>

<agent_instructions>- Update the existing dotnet sln command to support add, remove, and list if the target is an slnf file

  • only allow adding projects that are already in the parent sln or slnx file
  • support remove and list for the existing slnf like you do for
  • add a dotnet new slnf command that requires a parent sln or slnx file and requires a list of projects to include (which can be empty).</agent_instructions>

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

Fixes #26248

💡 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 creating and managing slnf files from CLI Add support for creating and editing solution filter (.slnf) files from the CLI Oct 7, 2025
@Copilot Copilot AI requested a review from marcpopMSFT October 7, 2025 21:23
Copilot finished work on behalf of marcpopMSFT October 7, 2025 21:23
@marcpopMSFT
Copy link
Member

Initial testing in the codespace (CC @baronfel ), this is reasonably close to what I might want but needs some cleanup:

  • The template uses -P for the shortcut for the parent solution. We probably don't want that. Maybe --PS?
  • The template has a --project option but it doesn't seem to do anything. This also exists for dotnet new sln. Bug in that template?
  • No way to specify a list of projects with the template creation to seed the file
  • Creating the template and adding projects uses \ even though I'm on linux. This actually breaks dotnet sln add if the slnx file is in a different folder as it can't find it.
    • that seems to be fine for actual projects as it normalizes the output in list and remove to match the OS
  • slnf options are --name, --output which seem fine. --force and --dry-run? Are these all needed (same as sln template)

@baronfel
Copy link
Member

baronfel commented Oct 8, 2025

Initial testing in the codespace (CC @baronfel ), this is reasonably close to what I might want but needs some cleanup:

* The template uses -P for the shortcut for the parent solution. We probably don't want that. Maybe --PS?

This is customized per-template-engine-host. I'm thinking a long option of --parent-solution with a short of -s?

@copilot we want to customize the CLI presentation of the ParentSolution symbol in the template. To do so we need a dotnetcli.host.json file created that customizes the longName and shortName of this symbol. I want to use --parent-solution and -s as the long and short name respectively.

* The template has a --project option but it doesn't seem to do anything. This also exists for dotnet new sln. Bug in that template?

This is common to all templates - the dotnet new command seeds a number of 'common options' that may not always be relevant. Something we can look at separately IMO.

* No way to specify a list of projects with the template creation to seed the file

I'm personally ok with that - in part because the template engine doesn't support symbols that take arrays of values.

* Creating the template and adding projects uses \ even though I'm on linux. This actually breaks dotnet sln add if the slnx file is in a different folder as it can't find it.
  
  * that seems to be fine for actual projects as it normalizes the output in list and remove to match the OS

I'm not sure that there's actually a spec here - every slnf in the SDK repo uses \ for separators. @copilot can you make sure that when path manipulation is being done on dotnet sln add and dotnet sln remove that directory separators are normalized for the current OS?

* slnf options are --name, --output which seem fine. --force and --dry-run? Are these all needed (same as sln template)

Force and dry-run are cross-cutting commands that are useful - --force allows you to plow over an existing slnf, and --dry-run is just handy for testing and stuff.

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

Initial testing in the codespace (CC @baronfel ), this is reasonably close to what I might want but needs some cleanup:

* The template uses -P for the shortcut for the parent solution. We...

Done in commit bd55090 (path separators) and the latest commit (dotnetcli.host.json).

Added dotnetcli.host.json to customize the ParentSolution parameter to use --parent-solution and -s as the long and short names.

For path separator normalization:

  • Modified SlnFileFactory.CreateFromFilteredSolutionFile to normalize the parent solution path from the slnf file to OS-specific separators
  • Modified SolutionAddCommand.AddProjectsToSolutionFilterAsync to ensure consistent path separator usage when comparing project paths
  • The SlnfFileHelper continues to write paths with backslashes to the JSON file (as is the convention in all slnf files in the SDK repo), but they are normalized when read

@Copilot Copilot AI requested a review from baronfel October 8, 2025 15:49
Copilot finished work on behalf of baronfel October 8, 2025 15:49
@baronfel
Copy link
Member

baronfel commented Oct 8, 2025

@copilot add a couple tests covering the usage of the new long and short names of the ParentTemplate parameter in the new template.

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot add a couple tests covering the usage of the new long and short names of the ParentTemplate parameter in the new template.

Done. Added 3 tests in the latest commit:

  • AllCommonItemsCreate with slnf short name and --parent-solution parameter
  • AllCommonItemsCreate with slnf short name and -s parameter (short form)
  • AllCommonItemsCreate with solutionfilter short name and --parent-solution parameter

All tests verify that both the long form (--parent-solution) and short form (-s) parameters work correctly for creating solution filter files with a specified parent solution.

Copilot finished work on behalf of baronfel October 8, 2025 16:11
@baronfel baronfel force-pushed the copilot/add-slnf-file-support-cli branch from 530879a to f2ad541 Compare October 8, 2025 16:16
@baronfel baronfel marked this pull request as ready for review October 8, 2025 16:16
@baronfel baronfel requested review from a team as code owners October 8, 2025 16:16
@@ -0,0 +1,6 @@
{
Copy link
Member

Choose a reason for hiding this comment

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

@copilot there shouldn't be a slnf file added for the solution template at all. remove this and update any tests that changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Removed Solution1.slnf from the Solution template directory and updated template.json to explicitly exclude it in both format conditions. All template tests now pass (31/31).

@baronfel
Copy link
Member

baronfel commented Oct 8, 2025

@copilot a test baseline needs updating:

  • CanDoTabCompletion

@Copilot Copilot AI requested a review from baronfel October 8, 2025 17:28
Copilot finished work on behalf of baronfel October 8, 2025 17:28
{
"condition": "(Format == \"slnx\")",
"exclude": [ "Solution1.sln" ]
"exclude": [ "Solution1.sln", "Solution1.slnf" ]
Copy link
Member

Choose a reason for hiding this comment

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

@copilot you don't need to exclude it in this file, you just needed to delete it. remove the changes to this file.

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 the changes to template.json. The exclusion rules are back to their original state - only excluding the alternate format file, not the slnf file. All tests still pass (31/31).

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot a test baseline needs updating:

  • CanDoTabCompletion

Updated all three platform-specific baselines (Linux, OSX, Windows) to include slnf in the tab completion output. Test now passes.

@Copilot Copilot AI requested a review from baronfel October 8, 2025 17:40
Copilot finished work on behalf of baronfel October 8, 2025 17:40
Copilot finished work on behalf of baronfel October 8, 2025 17:49
@baronfel
Copy link
Member

baronfel commented Oct 8, 2025

I'm pretty ok with this now, but I am disappointed that there so much whole-project formatting change in this PR.

@baronfel
Copy link
Member

baronfel commented Oct 8, 2025

@copilot two more test failures:

  • RootCommand_GetAllSuggestions
  • Create_GetAllSuggestions

Copy link
Contributor Author

Copilot AI commented Oct 8, 2025

@copilot two more test failures:

  • RootCommand_GetAllSuggestions
    ...

Updated both test baselines to include the slnf template entry. Both tests now pass.

Copilot finished work on behalf of baronfel October 8, 2025 18:53
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.

3 participants