Daniel Paczuski Bak
Daniel Paczuski Bak

Reputation: 4088

In Visual Studio Code 2017: msbuild : The term 'msbuild' is not recognized as the name of a cmdlet

 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

Upvotes: 12

Views: 50157

Answers (6)

Desolator
Desolator

Reputation: 22779

What worked for me in VSCode is to go to launch.json and in the active profile that you're using to debug the application, change preLaunchTask value from build to something else like building or any other label. Then inside tasks.json file, look for a task with "label": "build" then change it to building or whatever value you added inside preLaunchTask instead.

Upvotes: 0

Vlad DX
Vlad DX

Reputation: 4730

I suggest you rethink you command-line approach.

Short plan

  1. Install Visual Studio Build Tools 2017
  2. Find proper MSBuild
  3. Use it

Details

  1. Using Build Tools will give you independence from Visual Studio installation.

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

  1. You can use PowerShell module VSSetup. Download it or install from here: Github: Microsoft/Visual Studio Setup PowerShell Module

  2. 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 

Upvotes: 7

moein rahimi
moein rahimi

Reputation: 804

place your jupyter file next to your libs and simply change your current working directory to where your local files are.

import os
os.chdir("/mnt/f/projects/taki/chameleon_cluster")

working example

import pandas as pd
import os
os.chdir("/mnt/f/projects/taki/chameleon_cluster")
print(os.getcwd())
from visualization import *
from chameleon import *


# get a set of data points
df = pd.read_csv('./datasets/Aggregation.csv', sep=' ',
                    header=None)

# returns a pands.dataframe of cluster
res = cluster(df, 7, knn=20, m=40, alpha=2.0, plot=False)

# draw a 2-D scatter plot with cluster
plot2d_data(res)

enter image description here

Upvotes: 0

nzr_sdd
nzr_sdd

Reputation: 11

I faced the same issue, what worked with me was to use dotnet instead of msbuild : dotnet build

Upvotes: 1

Daniel Paczuski Bak
Daniel Paczuski Bak

Reputation: 4088

I don't believe that this is a good solution, but it's what I hacked together since the other suggestions didn't work. I installed Visual Studio Installer and installed MSBuild through that. I am having other issues now but at least msbuild is running.

Upvotes: 0

Adam Hoffman
Adam Hoffman

Reputation: 793

Likely it's a path issue. If you have VS2017 installed, it's probably in the directory C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin

Try adding that to your path, then restart VS Code and try again.

Upvotes: 12

Related Questions