.net-coredotnet-cli

.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) ?


Solution

  • .NET Core 1.0 Preview (project.json)

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

    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
    }