How can I use PowerShell with the Visual Studio Command Prompt?

前端 未结 9 1713
一向
一向 2020-12-02 03:44

I\'ve been using Beta 2 for a while now and it\'s been driving me nuts that I have to punt to cmd.exe when running the VS2010 Command Prompt. I used to have a nice vsvars200

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 04:30

    As an extension to Andy S's answer above, this is updated for VS 2019 community. However, I also needed 64-bit, so this includes the -arch=amd64 and -host_arch=amd64 flags as well for anyone that needs them.

    pushd "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\Tools"
    cmd /c "VsDevCmd.bat -arch=amd64 -host_arch=amd64&set " |
    foreach {
      if ($_ -match "=") {
        $v = $_.split("="); set-item -force -path "ENV:\$($v[0])"  -value "$($v[1])"
      }
    }
    popd
    Write-Host "`nVisual Studio 2019 Command Prompt variables set." -ForegroundColor Yellow
    

提交回复
热议问题