Search code examples
c#visual-studiosolutionsln-file

Is there an easy way to add multiple projects to a solution?


In some solutions I use direct references to internal projects during development and switch to nuget references for release. However, adding 30+ projects to new solutions manually is a tedious task.

I was wondering whether there is a quicker way to do this. With projects it's pretty easy because you just copy/paste the xml but solution files are not that easy to edit but maybe there is some trick?


Solution

  • You can use the dotnet CLI.

    For Linux:

    dotnet sln MySolution.sln add **/*.csproj
    

    For Windows PowerShell:

    dotnet sln MySolution.sln add (Get-ChildItem -Recurse *.csproj)