0
votes

VSCode tasks.json args do not parse as expected to MSBuild

I want to change the output to another directory. Addint "-o Z:/${workspaceFolderBasename}/bin/Debug/netcoreapp3.0/" into my dotnet build args did not work. (It errors with MSBUILD : error MSB1001: Unknown switch)

Solution: Add two args "-o" and "OutputPath" instead of "-o OutputpPath"

tasks.json

{
"version": "2.0.0",
"tasks": [
    {
        "label": "build",
        "command": "dotnet",
        "type": "process",
        "args": [
            "build",
            "${workspaceFolder}/Core3WinForms.csproj",
            // "-o Z:/${workspaceFolderBasename}/bin/Debug/netcoreapp3.0/" // that one won't work
            "-o",
            "Z:/${workspaceFolderBasename}/bin/Debug/netcoreapp3.0/"
        ],
        "problemMatcher": "$msCompile"
    }
]
}

output:

Executing task: C:\Program Files\dotnet\dotnet.exe build >C:\Dev\NoControl\Core3WinForms/Core3WinForms.csproj -o >Z:/Core3WinForms/bin/Debug/netcoreapp3.0/ <

Microsoft (R)-Build-Engine, Version 16.0.225-preview+g5ebeba52a1 für .NET Core Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

MSBUILD : error MSB1001: Unbekannter Schalter. Schalter: -o Z:/Core3WinForms/bin/Debug/netcoreapp3.0/

Informationen zur Schaltersyntax erhalten Sie, wenn Sie "MSBuild /help" eingeben. The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

Executing task: C:\Program Files\dotnet\dotnet.exe build C:\Dev\NoControl\Core3WinForms/Core3WinForms.csproj -o Z:/Core3WinForms/bin/Debug/netcoreapp3.0/ <

Microsoft (R)-Build-Engine, Version 16.0.225-preview+g5ebeba52a1 für .NET Core Copyright (C) Microsoft Corporation. Alle Rechte vorbehalten.

Wiederherstellung in "49,17 ms" für "C:\Dev\NoControl\Core3WinForms\Core3WinForms.csproj" abgeschlossen. C:\Program Files\dotnet\sdk\3.0.100-preview-009812\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(142,5): message NETSDK1057: Sie arbeiten mit einer Vorschauversion des .NET Core SDK. Sie können die SDK-Version über eine Datei "global.json" im aktuellen Projekt definieren. Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=869452. [C:\Dev\NoControl\Core3WinForms\Core3WinForms.csproj] Core3WinForms -> Z:\Core3WinForms\bin\Debug\netcoreapp3.0\Core3WinForms.dll

Der Buildvorgang wurde erfolgreich ausgeführt. 0 Warnung(en) 0 Fehler

Verstrichene Zeit 00:00:02.63

excuting task: C:\Program Files\dotnet\dotnet.exe build C:\Dev\NoControl\Core3WinForms/Core3WinForms.csproj -o Z:/Core3WinForms/bin/Debug/netcoreapp3.0/ < Should work just fine.

1

1 Answers

1
votes

Add two args "-o" and "OutputPath" instead of "-o OutputpPath"

Still not sure if this is a bug or a feature, and whose fault it really is, VSCode? MSBuild? Maybe it is my fault using insider builds (VSCode) and previews (netcore 3), but that solution worked for me.

I am just posting to help others, not to push my rep, I couldn't care less tbh.