.Net Core构建解决方案

时间:2016-06-22 07:47:03

标签: .net-core dotnet-cli

如果您尝试从使用visual studio制作的解决方案的顶级目录中的命令行运行:

dotnet build

我的解决方案是这样的架构:

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

它将失败并出现以下错误:

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

如何构建解决方案而无需明确指定每个项目(然后没有相关的维护)?

4 个答案:

答案 0 :(得分:32)

您可以使用顶级目录中的通配符(位于.sln的位置)。

  • 使用project.json中的SolutionDir/Src/ProjectName

    dotnet build */**/project.json

  • project.json中的SolutionDir/ProjectName

    dotnet build **/project.json

答案 1 :(得分:1)

如果您到达此处,则在仅使用CLI参数的情况下使用dotnet CLI(v3.1.X)来构建SLN的命令。

dotnet build <PATH>/<TO>/<SLN_FILE>.sln

https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build#arguments

答案 2 :(得分:0)

要添加答案,如果要发布项目,请使用dotnet publish src\MyProject1\发布所有文件。

发布将包含定义为包含在project.json中的文件。

答案 3 :(得分:0)

使用dotnet CLI 2.1,它可以构建解决方案。 这是我的配置:

        {
            "label": "build",
            "command": "dotnet",
            "type": "process",
            "args": [
                "build",
                "${workspaceFolder}/SolutionName.sln",
                "/property:GenerateFullPaths=true"
            ],
            "problemMatcher": "$msCompile",
            "group": {
                "kind": "build",
                "isDefault": true
            }
        },