Browse Source

ci: Add scripts to add nuget to job environment on Windows

Brad King 1 year ago
parent
commit
0d44d2ea1a
3 changed files with 26 additions and 0 deletions
  1. 1 0
      .gitlab/.gitignore
  2. 4 0
      .gitlab/ci/nuget-env.ps1
  3. 21 0
      .gitlab/ci/nuget.ps1

+ 1 - 0
.gitlab/.gitignore

@@ -10,6 +10,7 @@
 /mingw
 /msvc*
 /ninja*
+/nuget
 /openmp
 /open-watcom*
 /orangec

+ 4 - 0
.gitlab/ci/nuget-env.ps1

@@ -0,0 +1,4 @@
+$pwdpath = $pwd.Path
+& "$pwsh" -File ".gitlab/ci/nuget.ps1"
+Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\nuget;$env:PATH"
+nuget | Select -First 1

+ 21 - 0
.gitlab/ci/nuget.ps1

@@ -0,0 +1,21 @@
+$erroractionpreference = "stop"
+
+$version = "6.9.1.3"
+$sha256sum = "562A2CE2D570D68DB4472CB82CDF1FC4245D5C73B84BC8361880CBE389702F65"
+$filename = "nuget-$version-win-i386-1"
+$tarball = "$filename.zip"
+
+$outdir = $pwd.Path
+$outdir = "$outdir\.gitlab"
+$ProgressPreference = 'SilentlyContinue'
+# This URL is only visible inside of Kitware's network.
+Invoke-WebRequest -Uri "https://cmake.org/files/dependencies/internal/$tarball" -OutFile "$outdir\$tarball"
+$hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256
+if ($hash.Hash -ne $sha256sum) {
+    exit 1
+}
+
+Add-Type -AssemblyName System.IO.Compression.FileSystem
+[System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir")
+Move-Item -Path "$outdir\$filename" -Destination "$outdir\nuget"
+Remove-Item "$outdir\$tarball"