gpt4 book ai didi

visual-studio-code - MSBUILD 从 tasks.json 失败,但从 VS Code 终端工作

转载 作者:行者123 更新时间:2023-12-03 23:13:11 26 4
gpt4 key购买 nike

我在 VS Code 1.32.3 下的 C# .net-core 项目的 tasks.json 中有一个构建任务。如果我在 tasks.json 中运行任务,它会失败并显示 MSBUILD:错误 MSB1001:未知开关。
开关:--run-time linux-arm

Executing task: C:\Program Files\dotnet\dotnet.exe publish --runtime linux-arm --configuration Debug --self-contained false M:\ProjectsGit\HelloWorldVSCode/HelloWorldVSCode.csproj <

Microsoft (R) Build Engine version 16.0.385-preview+g966cdf2ac6 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1001: Unknown switch.
Switch: --runtime linux-arm

如果我将相同的命令复制并粘贴到 VS Code 终端,它就可以工作! --runtime 开关中的错误在哪里?
PS M:\ProjectsGit\HelloWorldVSCode> dotnet.exe publish --runtime linux-arm --configuration Debug --self-contained false M:\ProjectsGit\HelloWorldVSCode/HelloWorldVSCode.csprojMicrosoft (R) Build Engine version 16.0.385-preview+g966cdf2ac6 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

Restore completed in 25.18 ms for M:\ProjectsGit\HelloWorldVSCode\HelloWorldVSCode.csproj.
C:\Program Files\dotnet\sdk\3.0.100-preview-010184\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(151,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [M:\ProjectsGit\HelloWorldVSCode\HelloWorldVSCode.csproj]
HelloWorldVSCode -> M:\ProjectsGit\HelloWorldVSCode\bin\Debug\netcoreapp3.0\linux-arm\HelloWorldVSCode.dll
HelloWorldVSCode -> M:\ProjectsGit\HelloWorldVSCode\bin\Debug\netcoreapp3.0\linux-arm\publish\
PS M:\ProjectsGit\HelloWorldVSCode>

最佳答案

确保在空格处分隔您的参数。代替:

"args": [
"publish",
"${workspaceFolder}/HelloWorldVSCode/HelloWorldVSCode.csproj",
"--runtime linux-arm",
"--configuration Debug",
"--self-contained",
],

试试这样的:
"args": [
"publish",
"${workspaceFolder}/HelloWorldVSCode/HelloWorldVSCode.csproj",
"--runtime",
"linux-arm",
"--configuration",
"Debug",
"--self-contained",
"false",
],

此处的 args 列表不适用于空格。或者,您可以利用 dotnet CLI 也可以容忍使用 = 的事实,因此以下内容也应该有效:
"args": [
"publish",
"${workspaceFolder}/HelloWorldVSCode/HelloWorldVSCode.csproj",
"--runtime=linux-arm",
"--configuration=Debug",
"--self-contained=false",
],

关于visual-studio-code - MSBUILD 从 tasks.json 失败,但从 VS Code 终端工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55356768/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com