Skip to content

Instantly share code, notes, and snippets.

@default-writer
Last active November 15, 2023 12:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save default-writer/24c8278a5e097123571857b4e40e2847 to your computer and use it in GitHub Desktop.
Save default-writer/24c8278a5e097123571857b4e40e2847 to your computer and use it in GitHub Desktop.
setup_environment_variables_for_build_tools
function Add-Path($Path) {
# Get the existing PATH and split it into an array
$existingPath = [Environment]::GetEnvironmentVariable("PATH", "Machine").Split([IO.Path]::PathSeparator)
# Check if the $Path is not in the existing PATH
if ($existingPath -notcontains $Path) {
# Add the $Path to the array
$existingPath += $Path
# Join the array into a string using the path separator
$newPath = $existingPath -join [IO.Path]::PathSeparator
# Set the modified PATH as the new environment variable
[Environment]::SetEnvironmentVariable("PATH", $newPath, "Machine")
}
}
$DOTNET_ROOT="c:\tools\dotnet"
[Environment]::SetEnvironmentVariable("DOTNET_ROOT", $DOTNET_ROOT, "Machine")
$perf="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Team Tools\Performance Tools\x64\"
$msbuild="C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\amd64"
$netsdk="C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools"
$csc="C:\Windows\Microsoft.NET\Framework64\v4.0.30319"
$dotnet="c:\tools\dotnet"
Add-Path $perf
Add-Path $msbuild
Add-Path $netsdk
Add-Path $csc
Add-Path $dotnet
$msys64="c:\tools\msy64"
$msys64ucrt64="c:\tools\msys64\ucrt64\bin"
$javahome="C:\tools\jdk"
$doxygen="C:\tools\doxygen"
$graphwiz="C:\tools\graphwiz"
$sysinternals="C:\tools\sys"
$winmerge="c:\tools\winmerge"
$meld="c:\tools\meld"
Add-Path $msys64ucrt64
Add-Path $msys64
Add-Path $javahome
Add-Path $doxygen
Add-Path $graphwiz
Add-Path $sysinternals
Add-Path $winmerge
Add-Path $meld
Add-Path c:\tools\nuget
Add-Path c:\tools\sonar
Add-Path c:\tools\pwsh
Add-Path c:\tools\python\Scripts
Add-Path c:\tools\python\Lib
Add-Path c:\tools\python
Add-Path c:\tools\node
Add-Path c:\tools\git\bin
Add-Path c:\tools\git
Add-Path c:\tools\jdk\bin
Add-Path c:\tools\jdk
Add-Path c:\tools\code\bin
Add-Path c:\tools\code
$sshwin="C:\Windows\System32\OpenSSH\"
$gitwin="C:\Program Files\Git\cmd"
$chocowin="C:\ProgramData\chocolatey\bin"
Add-Path $sshwin
Add-Path $gitwin
Add-Path $chocowin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment