Last active
July 14, 2024 01:10
-
-
Save codebytes/1ae354e736c88adef5b6f802597e3101 to your computer and use it in GitHub Desktop.
Revisions
-
codebytes revised this gist
Jul 5, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ $sourceNugetExe = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" $targetPath = "C:\Program Files\nuget" if (-not (Test-Path -LiteralPath $targetPath)) { -
codebytes revised this gist
Jul 5, 2021 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -23,14 +23,14 @@ if (-not (Test-Path -LiteralPath "$targetPath\nuget.exe")) { "nuget.exe already exists at $targetPath" } # Add the tools dir to the path which directly contains NuGet.exe and CredentialProvider.VSS.exe if (!($env:Path -like "*;$targetPath*")) { "Adding $targetPath to Path" $env:Path = "$targetPath;" + $env:Path $oldPath = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path).path $newPath=$oldPath+";$targetPath" Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name path -Value $newPath } else { "$targetPath already existed in Path" -
codebytes created this gist
Jul 5, 2021 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ $sourceNugetExe = "http://nuget.org/nuget.exe" $targetPath = "C:\Program Files\nuget" if (-not (Test-Path -LiteralPath $targetPath)) { try { New-Item -Path $targetPath -ItemType Directory -ErrorAction Stop | Out-Null #-Force } catch { Write-Error -Message "Unable to create directory '$targetPath'. Error was: $_" -ErrorAction Stop } "Successfully created directory '$targetPath'." } else { "$targetPath already existed" } if (-not (Test-Path -LiteralPath "$targetPath\nuget.exe")) { "Downloading nuget.exe to $targetPath\nuget.exe" Invoke-WebRequest $sourceNugetExe -OutFile "$targetPath\nuget.exe" } else { "nuget.exe already exists at $targetPath" } # Add the tools dir to the path which directly contains NuGet.exe and CredentialProvider.VSS.exe if (!($env:Path -like "*$targetPath;*")) { "Adding $targetPath to Path" $env:Path = "$targetPath;" + $env:Path $originalpaths = (Get-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PSModulePath).PSModulePath $newPath=$originalpaths+";$targetPath" Set-ItemProperty -Path ‘Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment’ -Name PSModulePath –Value $newPath } else { "$targetPath already existed in Path" }