diff --git a/init.ps1 b/init.ps1 index 8bb78ad8..9c62b5e7 100755 --- a/init.ps1 +++ b/init.ps1 @@ -126,40 +126,40 @@ try { } } - $InstallNuGetPkgScriptPath = "$PSScriptRoot\tools\Install-NuGetPackage.ps1" + $DownloadNuGetPkgScriptPath = "$PSScriptRoot\tools\Download-NuGetPackage.ps1" $nugetVerbosity = 'quiet' if ($Verbose) { $nugetVerbosity = 'normal' } $MicroBuildPackageSource = 'https://pkgs.dev.azure.com/devdiv/_packaging/MicroBuildToolset%40Local/nuget/v3/index.json' if ($Signing) { Write-Host "Installing MicroBuild signing plugin" -ForegroundColor $HeaderColor - & $InstallNuGetPkgScriptPath MicroBuild.Plugins.Signing -source $MicroBuildPackageSource -Verbosity $nugetVerbosity + & $DownloadNuGetPkgScriptPath -PackageId MicroBuild.Plugins.Signing -Source $MicroBuildPackageSource -Verbosity $nugetVerbosity $EnvVars['SignType'] = "Test" } if ($Setup) { Write-Host "Installing MicroBuild SwixBuild plugin..." -ForegroundColor $HeaderColor - & $InstallNuGetPkgScriptPath Microsoft.VisualStudioEng.MicroBuild.Plugins.SwixBuild -source $MicroBuildPackageSource -Verbosity $nugetVerbosity + & $DownloadNuGetPkgScriptPath -PackageId Microsoft.VisualStudioEng.MicroBuild.Plugins.SwixBuild -Source $MicroBuildPackageSource -Verbosity $nugetVerbosity } if ($OptProf) { Write-Host "Installing MicroBuild OptProf plugin" -ForegroundColor $HeaderColor - & $InstallNuGetPkgScriptPath MicroBuild.Plugins.OptProf -source $MicroBuildPackageSource -Verbosity $nugetVerbosity + & $DownloadNuGetPkgScriptPath -PackageId MicroBuild.Plugins.OptProf -Source $MicroBuildPackageSource -Verbosity $nugetVerbosity $EnvVars['OptProfEnabled'] = '1' } if ($Localization) { Write-Host "Installing MicroBuild localization plugin" -ForegroundColor $HeaderColor - & $InstallNuGetPkgScriptPath MicroBuild.Plugins.Localization -source $MicroBuildPackageSource -Verbosity $nugetVerbosity + & $DownloadNuGetPkgScriptPath -PackageId MicroBuild.Plugins.Localization -Source $MicroBuildPackageSource -Verbosity $nugetVerbosity $EnvVars['LocType'] = "Pseudo" $EnvVars['LocLanguages'] = "JPN" } if ($SBOM) { Write-Host "Installing MicroBuild SBOM plugin" -ForegroundColor $HeaderColor - & $InstallNuGetPkgScriptPath MicroBuild.Plugins.Sbom -source $MicroBuildPackageSource -Verbosity $nugetVerbosity + & $DownloadNuGetPkgScriptPath -PackageId MicroBuild.Plugins.Sbom -Source $MicroBuildPackageSource -Verbosity $nugetVerbosity # The feed with the latest versions of the tool is at 'https://1essharedassets.pkgs.visualstudio.com/1esPkgs/_packaging/SBOMTool/nuget/v3/index.json', # but we'll use the feed that the SBOM task itself uses to install the tool for consistency. - $PkgMicrosoft_ManifestTool_CrossPlatform = & $InstallNuGetPkgScriptPath Microsoft.ManifestTool.CrossPlatform -source $MicroBuildPackageSource -Verbosity $nugetVerbosity + $PkgMicrosoft_ManifestTool_CrossPlatform = & $DownloadNuGetPkgScriptPath -PackageId Microsoft.ManifestTool.CrossPlatform -Source $MicroBuildPackageSource -Verbosity $nugetVerbosity $EnvVars['GenerateSBOM'] = "true" $EnvVars['PkgMicrosoft_ManifestTool_CrossPlatform'] = $PkgMicrosoft_ManifestTool_CrossPlatform } diff --git a/tools/Convert-PDB.ps1 b/tools/Convert-PDB.ps1 index 7e1303a2..ad007996 100644 --- a/tools/Convert-PDB.ps1 +++ b/tools/Convert-PDB.ps1 @@ -10,11 +10,11 @@ #> [CmdletBinding()] Param( - [Parameter(Mandatory=$true,Position=0)] + [Parameter(Mandatory = $true, Position = 0)] [string]$DllPath, [Parameter()] [string]$PdbPath, - [Parameter(Mandatory=$true,Position=1)] + [Parameter(Mandatory = $true, Position = 1)] [string]$OutputPath ) @@ -25,24 +25,26 @@ if ($IsMacOS -or $IsLinux) { $version = '1.1.0-beta2-21101-01' $baseDir = "$PSScriptRoot/../obj/tools" -$pdb2pdbpath = "$baseDir/Microsoft.DiaSymReader.Pdb2Pdb.$version/tools/Pdb2Pdb.exe" +$pdb2pdbpath = "$baseDir/microsoft.diasymreader.pdb2pdb/$version/tools/Pdb2Pdb.exe" if (-not (Test-Path $pdb2pdbpath)) { if (-not (Test-Path $baseDir)) { New-Item -Type Directory -Path $baseDir | Out-Null } $baseDir = (Resolve-Path $baseDir).Path # Normalize it - Write-Verbose "& (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json | Out-Null" # This package originally comes from the https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json feed. # Add this feed as an upstream to whatever feed is in nuget.config if this step fails. - & (& $PSScriptRoot/Get-NuGetTool.ps1) install Microsoft.DiaSymReader.Pdb2Pdb -version $version -PackageSaveMode nuspec -OutputDirectory $baseDir | Out-Null - if ($LASTEXITCODE -ne 0) { + try { + & "$PSScriptRoot/Download-NuGetPackage.ps1" -PackageId Microsoft.DiaSymReader.Pdb2Pdb -Version $version -Source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json -OutputDirectory $baseDir | Out-Null + } + catch { Write-Error "Failed to install Microsoft.DiaSymReader.Pdb2Pdb. Consider adding https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json as an upstream to your nuget.config feed." return } + $pdb2pdbpath = "$baseDir/microsoft.diasymreader.pdb2pdb/$version/tools/Pdb2Pdb.exe" } -$args = $DllPath,'/out',$OutputPath,'/nowarn','0021' +$arguments = $DllPath, '/out', $OutputPath, '/nowarn', '0021' if ($PdbPath) { - $args += '/pdb',$PdbPath + $arguments += '/pdb', $PdbPath } -Write-Verbose "$pdb2pdbpath $args" -& $pdb2pdbpath $args +Write-Verbose "$pdb2pdbpath $arguments" +& $pdb2pdbpath $arguments diff --git a/tools/Download-NuGetPackage.ps1 b/tools/Download-NuGetPackage.ps1 index 924b9edf..ce31167a 100644 --- a/tools/Download-NuGetPackage.ps1 +++ b/tools/Download-NuGetPackage.ps1 @@ -42,14 +42,16 @@ if ($Version) { $packageArg = "$PackageId@$Version" } $extraArgs = @() if ($Source) { $extraArgs += '--source', $Source } +if ($Version -and $Version -match '-') { $extraArgs += '--prerelease' } $prevErrorActionPreference = $ErrorActionPreference $ErrorActionPreference = 'Continue' -& dotnet package download $packageArg --configfile $ConfigFile --output $OutputDirectory --verbosity $Verbosity @extraArgs 2>&1 | Out-Null +$downloadOutput = & dotnet package download $packageArg --configfile $ConfigFile --output $OutputDirectory --verbosity $Verbosity @extraArgs 2>&1 $downloadExitCode = $LASTEXITCODE $ErrorActionPreference = $prevErrorActionPreference if ($downloadExitCode -ne 0) { + $downloadOutput | Write-Host throw "Failed to download package $packageArg (exit code $downloadExitCode)." }