Created
May 16, 2016 19:16
-
-
Save mowensoft/e63533aa7a0e4dcd83ee73c220ce8ecd to your computer and use it in GitHub Desktop.
Updates NuGet in Visual Studio 2015. Assumes you installed Visual Studio 2015 to the default path.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function IsVisualStudioRunning { | |
Try { | |
$visualStudioInstances = (Get-Process devenv) | |
return ($visualStudioInstances.Length -gt 0) | |
} | |
Catch { | |
return $false | |
} | |
} | |
function RemoveExistingExtensionFoldersContainingNuGet { | |
Write-Output 'Removing old installations of NuGet...' | |
$extensionsDir = "$env:ProgramFiles\Microsoft Visual Studio 14.0\Common7\IDE\Extensions" | |
Get-ChildItem -Recurse $extensionsDir -Include "NuGet.VisualStudio.Implementation.dll" | Select -ExpandProperty Directory | Remove-Item -Recurse -Force | |
} | |
function DownloadAndInstallNugetExtension { | |
Write-Output 'Downloading latest distribution of NuGet for Visual Studio 2015...' | |
$source = 'https://dist.nuget.org/visualstudio-2015-vsix/latest/NuGet.Tools.vsix' | |
$temp = [System.IO.Path]::GetTempPath() | |
$destination = (Join-Path $temp 'NuGet.Tools.vsix') | |
Invoke-WebRequest $source -OutFile $destination | |
Write-Output 'Installing NuGet...' | |
& "$env:ProgramFiles\Microsoft Visual Studio 14.0\Common7\IDE\VSIXInstaller" /q $destination | |
} | |
function Main { | |
if (IsVisualStudioRunning) { | |
Write-Error 'Please close all instances of Visual Studio before proceeding. I would kill them for you but I probably don''t have permission.' | |
return | |
} | |
RemoveExistingExtensionFoldersContainingNuGet | |
DownloadAndInstallNugetExtension | |
} | |
Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment