Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.Net Core build a solution

If you try to run from the command line in the top directory of a solution made with visual studio:

dotnet build 

My solution is architectured like that:

MySolution.sln    > src        > MyProject1            > project.json        > MyProject2            > project.json    > test        > MyProject.Test            > project.json 

it will fail with the following error:

Couldn't find 'project.json' in current directory 

How could I build the solution without having to specify each project explicitely (and then without the related maintenance) ?

like image 669
Fab Avatar asked Jun 22 '16 07:06

Fab


People also ask

What can you build with .NET Core?

With ASP.NET Core, you can: Build web apps and services, Internet of Things (IoT) apps, and mobile backends. Use your favorite development tools on Windows, macOS, and Linux.

Is .NET Core being discontinued?

Note: The . NET 5.0 SDK versions will continue to be supported in VS 16.11 until December of 2022 when . NET Core 3.1 goes out of support so that . NET Core 3.1 customers can continue to use 16.11 to developer their applications.

How do I publish an entire solution in Visual Studio?

To publish from Visual Studio, do the following: Change the solution configuration from Debug to Release on the toolbar to build a Release (rather than a Debug) version of your app. Right-click on the project (not the solution) in Solution Explorer and select Publish. In the Publish tab, select Publish.

How do I create a dotnet solution file?

Create a solution file To use the dotnet sln command, the solution file must already exist. If you need to create one, use the dotnet new command with the sln template name.


1 Answers

.NET Core 1.0 Preview (project.json)

You can use wildcards like that from the top directory (where lies the .sln).

  • With the project.json in SolutionDir/Src/ProjectName:

    dotnet build */**/project.json

  • If project.json in SolutionDir/ProjectName:

    dotnet build **/project.json

Note: It's recommended to migrate to new csproj project format to get support and new features.

Since .NET Core 1.0 RTM

The solution is back for good.

  dotnet build solution.sln 

In powershell, build all csproj file under the current directory.

foreach ($csproj in $(Get-ChildItem -Recurse . -Filter *.csproj) ) {     dotnet build $csproj.FullName } 
like image 75
Fab Avatar answered Sep 25 '22 17:09

Fab