Skip to content

How to organize project within folders #114

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
MarvinKlein1508 opened this issue Mar 20, 2025 · 1 comment
Open

How to organize project within folders #114

MarvinKlein1508 opened this issue Mar 20, 2025 · 1 comment

Comments

@MarvinKlein1508
Copy link

Hi there,

I've tried out the new SLNX format for solution files within VS Preview Version 17.14.0 Preview 2.0.

I really like the new format since it is way easier to modify. However I'm still trying to figure out how I can organize my project from within Visual Studio without any clutter in mit GitHub repository.

For example. lets say I want all my code to be displayed within a src folder and all my tests within a test folder.

So I add two new solution folders via the context menu:

Image

Now I move my project to the src folder and create a new one within the tests folder. In VS it looks like this:

Image

However on the filesystem you'll get:

Image

The SLNX file will look like this:

<Solution>
  <Folder Name="/src/">
    <Project Path="ConsoleApp2/ConsoleApp2.csproj" />
  </Folder>
  <Folder Name="/tests/">
    <Project Path="TestProject1/TestProject1.csproj" />
  </Folder>
</Solution>

but how can I achieve this within VS? Via command line I would do mkdir src then mkdir tests create the projects within this files and then call dotnet sln add path_to_csproj

@edvilme
Copy link
Contributor

edvilme commented Apr 25, 2025

Solution Folders as a concept do not necessarily match the file-system directories.
When adding projects using dotnet sln add, the CLI automatically generates solution folders based on the path to the project. However, these concepts stay decoupled: moving the files in the filesystem will not update the solution file, nor the other way around.

I would suggest removing the projects from the solution file, moving them to where you want them to be, and then adding the new project paths.

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

No branches or pull requests

2 participants