When I clone the repo I want to add a C# project in visual studio. But I cant seem to build the project, since its not in a solution folder. How can I add an Solution folder to an already existing git repo consisting of some projects?
Asked
Active
Viewed 2,435 times
-1
-
Why do you need a folder? I'm really not clear what you are asking here. Perhaps speak to the person who made the repo, maybe they just forgot to include the sln file. – DavidG Mar 23 '21 at 13:38
-
Can you share the build error you are seeing? It should not be related to a missing sln file but we can discover it – Jorge Cupi Mar 23 '21 at 13:45
-
Make Sure, Your Visual Studio Project and project cloned from Git are same. Mostly It happens – Allahbakash.G Mar 23 '21 at 16:21
1 Answers
1
If your file structure is like:
.git/
Project1/Project1.csproj
Project2/Project2.csproj
You go to the project root, and run the following in your powershell prompt:
# Create a new solution file
dotnet new sln
# Add all csproj files to it
dotnet sln add (Get-Item **/*.csproj)
You may now open the *.sln
file directly within visual studio.

galdin
- 12,411
- 7
- 56
- 71
-
You're assuming two things. 1 - that it is a .NET Core projects. and 2 - the OP wants to add the sln file to the repo. – DavidG Mar 23 '21 at 13:42
-
1