Use PowerShell for Visual Studio Command Prompt

前端 未结 5 1380
故里飘歌
故里飘歌 2021-01-30 23:33

In a serious intiative to migrate all my command line operations to PowerShell, I would like to avoid using the old fashioned command console for anything. However, the Visual

相关标签:
5条回答
  • 2021-01-31 00:03

    You can use for example this script to import Visual Studio command prompt environment, see the examples in the script documentation comments, e.g. for Visual Studio 2010:

    Invoke-Environment '"%VS100COMNTOOLS%\vsvars32.bat"' 
    

    Having done that in the beginning of a PowerShell session (from your profile or manually), you get what you ask for in this PowerShell session.

    Or you can use the solution provided by Keith Hill in this answer.

    0 讨论(0)
  • 2021-01-31 00:07

    I use this script that I call Initialize-VisualStudio.ps1, i call it in my profile with dot source, to set the environment variables need it, in my actual session:

    param([switch]$ArquitectureX86)
    if($ArquitectureX86)
    { $arq= "x86"}
    else
    { $arq="x64"}
    pushd 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC'
    cmd /c "vcvarsall.bat $arq&set" |
    foreach {
      if ($_ -match "=") {
      $v = $_.split("="); set-item -force -path "ENV:\$($v[0])" -value "$($v[1])"; 
    }
    }
    popd
    
    0 讨论(0)
  • 2021-01-31 00:20

    have a look at PowerConsole

    0 讨论(0)
  • 2021-01-31 00:20

    PowerConsole has been incorporated into NuGet http://nuget.codeplex.com/. You get PowerShell inside Visual Studio and a package management system.

    0 讨论(0)
  • 2021-01-31 00:21

    What I do is create a simple cmd batch command script that looks like this:

    call "%VS80COMNTOOLS%vsvars32.bat"
    powershell
    

    Then I create a shortcut that invokes this through cmd. The shortcut target looks like:

    %windir%\System32\cmd.exe /k "SetupPSBuildEnvironment.cmd"
    

    If you want the console to look like the powershell console, just modify the Layout to your liking in the shortcut properties.

    0 讨论(0)
提交回复
热议问题