[英].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:如果您尝试从使用 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) ?我如何构建解决方案而不必明确指定每个项目(然后没有相关维护)?
You can use wildcards like that from the top directory (where lies the .sln).您可以使用顶级目录(.sln 所在的位置)中的通配符。
With the project.json
in SolutionDir/Src/ProjectName
:使用
SolutionDir/Src/ProjectName
的project.json
:
dotnet build */**/project.json
If project.json
in SolutionDir/ProjectName
:如果在
SolutionDir/ProjectName
project.json
:
dotnet build **/project.json
Note: It's recommended to migrate to new csproj project format to get support and new features.注意: 建议迁移到新的 csproj 项目格式以获得支持和新功能。
The solution is back for good.解决方案又回来了。
dotnet build solution.sln
In powershell, build all csproj file under the current directory.在powershell中,构建当前目录下的所有csproj文件。
foreach ($csproj in $(Get-ChildItem -Recurse . -Filter *.csproj) )
{
dotnet build $csproj.FullName
}
If you arrive here looking for the command to build a SLN with dotnet
CLI (v3.1.X), using only CLI args, it's below.如果您到达这里寻找使用
dotnet
CLI (v3.1.X) 构建 SLN 的命令,仅使用 CLI args,它在下面。
dotnet build <PATH>/<TO>/<SLN_FILE>.sln
https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build#arguments https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build#arguments
To add to the answer, if you are publishing the project, use dotnet publish src\\MyProject1\\
to publish all the files.补充一点,如果您要发布项目,请使用
dotnet publish src\\MyProject1\\
发布所有文件。
Publishing will include files defined to be included in project.json.发布将包括定义为包含在 project.json 中的文件。
With dotnet CLI 2.1, it could build the solution.使用 dotnet CLI 2.1,它可以构建解决方案。 Here is my config:
这是我的配置:
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/SolutionName.sln",
"/property:GenerateFullPaths=true"
],
"problemMatcher": "$msCompile",
"group": {
"kind": "build",
"isDefault": true
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.