Add a project.json based project to a .sln file without using Visual Studio
Asked Answered
C

1

7

We have developers that are using VS Code on Linux, Windows, and Mac. We also have developers that are using full Visual Studio on Windows. A problem arises when the former (including me) do not add their projects to the solution, and the latter therefor do not see the projects in the solution.

How can developers add their project.json projects to a sln without having to open Visual Studio?

Cenobite answered 2/11, 2016 at 18:34 Comment(2)
Without manually editing the *.sln file? iirc VS Code doesn't use the sln/xproj files at all, just the project.json filesKlinger
Yes. We would like a way to do it without manually editing the SLN file.Cenobite
S
8

Nowadays .NET Core SDK allows working with sln files.

Imagine you have a root folder for the solution. All the projects are located under src and test folders.

Then from the solution folder run something like this:

dotnet sln add ./src/Insurance.Domain/Insurance.Domain.csproj
dotnet sln add ./test/Insurance.Domain.Tests/Insurance.Domain.Tests.csproj

You can list the projects in the solution runing

dotnet sln list

Note: The solution provided above is not going to work with project.json files. Anyway project.json format is obsolete now and you can easilty migrage to csprojs with the latest SDK. Just run in your project folder:

dotnet migrate

and you are good to go.

Silencer answered 11/3, 2017 at 13:25 Comment(3)
Thank you for the answer. For me to mark it as an answer, it will need to explain how to do the same thing with a project.json file.Cenobite
@ShaunLuttin, I haven't found any way to leverage dotnet sln for project.json files neither reading docs nor playing with it in CLI. I believe they support csproj, fsproj, etc. Project.json format is kind of obsolete now and new SDK produce only csproj files creating new projects via dotnet new. Have you considered to migrate to the new format? Just run dotnet migrate within project folder and you are good to go.Silencer
Considering integrating that comment into the answer, so that those who come looking for how to "add a project.json based project to a sln file without using Visual Studio" see an answer that is relevant to that use case.Cenobite

© 2022 - 2024 — McMap. All rights reserved.