从命令行安装VS.NET扩展

时间:2015-02-21 23:48:10

标签: visual-studio powershell

有没有办法从命令行安装VS.NET扩展?我正在使用vagrant和powershell设置开发虚拟机进行配置,并且希望能够自动安装一些我最喜欢的扩展。

3 个答案:

答案 0 :(得分:5)

您可以使用VSIXInstaller自动执行扩展安装:

enter image description here

答案 1 :(得分:1)

谢尔盖的回答是正确的,但这里是我用来自动化的powershell脚本(从我发现的巧克力包中偷来的):

function Get-Batchfile ($file) {
  $cmd = "`"$file`" & set"
    cmd /c $cmd | Foreach-Object {
      $p, $v = $_.split('=')
        Set-Item -path env:$p -value $v
    }
}

function VsVars32()
{
    $BatchFile = join-path $env:VS120COMNTOOLS "vsvars32.bat"
    Get-Batchfile `"$BatchFile`"
}

function curlex($url, $filename) {
  $path = [io.path]::gettemppath() + "\" + $filename
  if( test-path $path ) { rm -force $path }
  (new-object net.webclient).DownloadFile($url, $path)

  return new-object io.fileinfo $path
}

function installsilently($url, $name) {
  echo "Installing $name"
  $extension = (curlex $url $name).FullName
  $result = Start-Process -FilePath "VSIXInstaller.exe" -ArgumentList "/q $extension" -Wait -PassThru;
}


# INSTALL VS Extenaions
installsilently http://visualstudiogallery.msdn.microsoft.com/59ca71b3-a4a3-46ca-8fe1-0e90e3f79329/file/6390/49/VsVim.vsix VsVim.vsix

答案 2 :(得分:0)

我使用这个batch-install-vsix巧克力包来配置和安装扩展程序。