How to load and run a .NET 6 project without .SLN file using VS 2022--

P. G. Choudhury 146 Reputation points
2023-03-14T16:16:03.6633333+00:00

So basically my problem is - how do I run a .Net 6 Core project that does not have a .sln file.

I downloaded a sample code from github for a project but when I went ahead to browse the code I discovered that the project does not have any .sln file. There is a .csproj file though.

After loading the project[from folders option] I did a dotnet restore which completed ok.

But then how to run this project? A step by step guide would be of much help. I am using VS 2022.

Thanks. Some guidance needed.

Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | Other
Developer technologies | Visual Studio | Other
0 comments No comments
{count} votes

Accepted answer
  1. Michael Taylor 60,326 Reputation points
    2023-03-14T17:02:44.99+00:00

    A solution file is simply a virtual collection of projects. If you need a solution file then use File \ New Project. Then type Solution in the search field. You'll see the Blank Solution template, select it. You have to create the solution in an empty folder but otherwise it'll create the solution file.

    Once you have the blank solution either copy the solution file into your project directory or copy the project directory into the solution directory. After that load the solution and then right-click the solution in Solution Explorer and select Add Existing Project and select your project. You're done.

    Alternatively I believe if you loaded the project into Visual Studio then you can tell VS to save all and it'll prompt you to create a solution because projects need to be in solutions. I haven't tried this in a while though.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 78,006 Reputation points Volunteer Moderator
    2023-03-14T18:28:07.8966667+00:00

    solution files are just for visual studio (and msbuild), they are not used by dotnet.

    you should be able to just run

    dotnet run

    or build

    dotnet build

    and run the executable in the bin folder. the build will give path

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.