I am trying to build a collection of .vcxproj generated by Premake within VS Code. What I don't get is why it works for executing the premake generation but not the .vcxproj builds as the old batch files are the same except they call msbuild.exe with a full path.
** Visual Studio 2019 Developer Command Prompt v16.11.17 ** Copyright (c) 2021 Microsoft Corporation
Building configurations... Running action 'vs2019'... Done (160ms).
Terminal will be reused by tasks, press any key to close it.
Executing task: msbuild.exe SimClient.vcxproj && "/p:configuration=Debug Static" && /p:platform=x64
'C:/Program' is not recognized as an internal or external command, operable program or batch file.
This is my tasks.json there is more but it's just rinse and repeat.
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
// The path to VsDevCmd.bat depends on the version of Visual Studio you have installed.
"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
"&&"
]
}
}
},
"tasks": [
{
"type": "shell",
"label": "Generate Project",
"command": "${workspaceFolder}/packages/premake/premake5.exe",
"args": [ "vs2019" ],
"group": {
"kind": "build",
"isDefault": true
},
},
{
"type": "shell",
"label": "Build SimClient (Debug)",
"dependsOn": ["Generate Project"],
"command": "msbuild.exe" ,
"args": [
"SimClient.vcxproj",
"&&",
"/p:configuration=Debug Static",
"&&",
"/p:platform=x64"
],
"problemMatcher": [ "$msCompile" ],
"group": {
"kind": "build",
"isDefault": true
},
},
...
],
}
}
I managed to find a solution to this problem while trying to start a process in an external terminal. By replacing "command":"msbuild.exe" with "command":"cmd.exe" and moving the "msbuild.exe" into the argument list preceded by "/C" fixes the failing path string.
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "cmd.exe",
"args": [
"/C",
"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
"&&"
]
}
}
},
"tasks": [
{
"label": "Generate Project",
"type": "shell",
"command": "${workspaceFolder}/packages/premake/premake5.exe",
"args": [ "vs2019" ],
"group": {
"kind": "build",
"isDefault": false
},
},
{
"type":"shell",
"label": "Build (Debug)",
"command":"cmd.exe",
"args": [
"/C",
"msbuild.exe",
"SimClient.sln",
"/p:configuration=Debug;platform=x64"
],
"problemMatcher": [ "$msCompile" ],
"group": {
"kind": "build",
"isDefault": false
},
},
]
}