【发布时间】:2019-06-15 03:57:09
【问题描述】:
我无法让 VS Code 构建一个空的类库,而 dotnet core 可以很高兴。
在 PowerShell 中,我创建了一个名为 CoreTesting 的文件夹,导航到该文件夹并使用 code 启动 VS Code。
我点击CTRL + ` 进入终端并导航到解决方案的文件夹。
然后我输入dotnet new classlib --name Common,看到新建文件夹Common,输入dotnet build .\Common\构建类库。一切都很好。
我将 Common 文件夹添加到 VS Code 并点击 CTRL + SHIFT + B 并看到 No build task to run found. Configure Build Task...,所以我点击 return 并看到 Create tasks.json file from template,所以我再次点击 return 并看到:
MSBuildmaven.NET CoreOthers
所以我选择.NET Core 并看到创建了一个包含tasks.json 的.vscode 文件夹。该文件包含:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "silent"
},
"problemMatcher": "$msCompile"
}
]
}
我再次点击CTRL + SHIFT + B 并看到build Common 选项,所以我点击return 并看到这个:
> Executing task in folder Common: dotnet build <
Microsoft (R) Build Engine version 16.0.225-preview+g5ebeba52a1 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file.
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
我能看到的结构是这样的:
-
Common\-
.vscode\tasks.json
bin\obj\Class1.csCommon.csproj
-
我做错了什么?
【问题讨论】:
-
否;为了更清楚,我已将文件夹结构添加到帖子中。
标签: .net-core visual-studio-code build class-library vscode-tasks