Skip to content

Instantly share code, notes, and snippets.

@bradwilson
Last active March 4, 2020 19:09
Show Gist options
  • Select an option

  • Save bradwilson/29c039548c1cb80ca8d0 to your computer and use it in GitHub Desktop.

Select an option

Save bradwilson/29c039548c1cb80ca8d0 to your computer and use it in GitHub Desktop.
Add VS 2015 build tools to your path
param(
[Parameter(Mandatory=$true)][string]$pathToBeAdded
)
$local:oldPath = get-content Env:\Path
$local:newPath = $local:oldPath + ";" + $pathToBeAdded
set-content Env:\Path $local:newPath
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)][string] $Script,
[Parameter(Position=1, Mandatory=$false)][string] $Parameters
)
$tempFile = [IO.Path]::GetTempFileName()
cmd /c " `"$script`" $parameters && set > `"$tempFile`" "
Get-Content $tempFile | %{
if ($_ -match "^(.*?)=(.*)$") {
Set-Content "env:\$($matches[1])" $matches[2]
}
}
Remove-Item $tempFile
param(
[switch]$noWebTools
)
if (test-path Env:\VS140COMNTOOLS) {
$vsvars32 = [System.IO.Path]::GetFullPath((join-path (get-content Env:\VS140COMNTOOLS) "vsvars32.bat"))
if (test-path $vsvars32) {
write-host "Setting environment for Microsoft Visual Studio 2015."
invoke-cmdscript $vsvars32
if ($noWebTools -eq $false) {
$webTools = [System.IO.Path]::GetFullPath((join-path (get-content Env:\VS140COMNTOOLS) "..\IDE\Extensions\Microsoft\Web Tools\External"))
if (test-path $webTools) {
write-host "Adding Web Tools external tools to the PATH."
append-path $webTools
}
}
}
else {
write-warning ("Cannot find " + $vsvars32)
}
}
else {
write-warning "Visual Studio 2015 is not installed."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment