msbuild : The term 'msbuild' is not recognized as the name of a cmdlet,
function, script file, or operable program.
As far as my googling goes, Visual Code should come with MSbuild. I have installed the C/C++ and msbuild Tools extensions to no avail. What can I do?
Edit: I am using Visual Studio Code 1.19.2
I suggest you rethink you command-line approach.
Short plan
Details
Download Build Tools for Visual Studio 2017 (direct link)
Command-line arguments documented here: Use command-line parameters to install Visual Studio 2017
All workloads and components are listed here: Visual Studio Build Tools 2017 component directory
You can use PowerShell module VSSetup
. Download it or install from here: Github: Microsoft/Visual Studio Setup PowerShell Module
Run MSBuild with build
target (you can add additional required parameters)
# 1. Find MS Build
Import-Module $PSScriptRoot\VSSetup\VSSetup.psd1
$msBuildPath = (Get-VSSetupInstance | Select-VSSetupInstance -Version 15.0 -Product Microsoft.VisualStudio.Product.BuildTools).InstallationPath
if ([System.IntPtr]::Size -eq 8)
{
$global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin\amd64'
}
else
{
$global:msbuildPath = Join-Path $msBuildPath 'MSBuild\15.0\Bin'
}
Write-Output "Using MSBuild from $global:msbuildPath"
Write-Output "MSBuild /version"
$msbuild = Join-Path $global:msbuildPath msbuild
& $msbuild /version
# 2. Build
& $msbuild "$sln_file" /t:Build /v:q /nologo