From 2e0c96eb37de53f5aab20da7a5f2081c28de5084 Mon Sep 17 00:00:00 2001 From: v-pegao Date: Fri, 10 Sep 2021 15:42:06 +0800 Subject: [PATCH] use nuget 5.9.1 for azure pipelines (#7608) --- azure-pipelines-master.yml | 2 ++ azure-pipelines-stable.yml | 2 ++ pack.ps1 | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/azure-pipelines-master.yml b/azure-pipelines-master.yml index bc378731cc0..5e2ae061917 100644 --- a/azure-pipelines-master.yml +++ b/azure-pipelines-master.yml @@ -30,6 +30,8 @@ steps: - task: NuGetToolInstaller@1 displayName: 'Use NuGet' + inputs: + versionSpec: 5.9.1 - task: CmdLine@1 displayName: 'npm install' diff --git a/azure-pipelines-stable.yml b/azure-pipelines-stable.yml index e857a6217fd..89aa8f58f6a 100644 --- a/azure-pipelines-stable.yml +++ b/azure-pipelines-stable.yml @@ -30,6 +30,8 @@ steps: - task: NuGetToolInstaller@1 displayName: 'Use NuGet' + inputs: + versionSpec: 5.9.1 - task: CmdLine@1 displayName: 'npm install' diff --git a/pack.ps1 b/pack.ps1 index 736ab11c100..7730d09b915 100644 --- a/pack.ps1 +++ b/pack.ps1 @@ -17,6 +17,7 @@ else{ $os = GetOperatingSystemName Write-Host "Running on OS $os" +$globalNugetCommand = 'nuget' $nugetCommand = GetNuGetCommand ($os) $scriptPath = $MyInvocation.MyCommand.Path $scriptHome = Split-Path $scriptPath @@ -39,13 +40,19 @@ if (-not(ValidateCommand("dotnet"))) { } # Check if nuget.exe exists -if (-not(ValidateCommand($nugetCommand))) { +if (ValidateCommand($globalNugetCommand)) { + $nugetCommand = $globalNugetCommand +} elseIf (-not(ValidateCommand($nugetCommand))) { Write-Host "Downloading NuGet.exe..." mkdir -Path "$env:LOCALAPPDATA/Nuget" -Force $ProgressPreference = 'SilentlyContinue' [Net.WebRequest]::DefaultWebProxy.Credentials = [Net.CredentialCache]::DefaultCredentials - Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile $nugetCommand + + # Pin Nuget version to v5.9.1 to workaround for Nuget issue: https://github.com/NuGet/Home/issues/11125 + # Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/latest/nuget.exe' -OutFile $nugetCommand + Invoke-WebRequest 'https://dist.nuget.org/win-x86-commandline/v5.9.1/nuget.exe' -OutFile $nugetCommand } +Write-Host "Using Nuget Command: $nugetCommand, $(& $nugetCommand help | Select -First 1)" # dotnet pack first foreach ($proj in (Get-ChildItem -Path ("src", "plugins") -Include *.[cf]sproj -Exclude 'docfx.msbuild.csproj' -Recurse)) { @@ -101,9 +108,9 @@ $packages = @{ "nuspecs" = @("src/nuspec/YamlSplitter/YamlSplitter.nuspec"); }; "SandcastleRefMapper" = @{ - "proj" = $null; - "nuspecs" = @("src/nuspec/SandcastleRefMapper/SandcastleRefMapper.nuspec") - }; + "proj" = $null; + "nuspecs" = @("src/nuspec/SandcastleRefMapper/SandcastleRefMapper.nuspec") + }; } # Pack plugins and tools