From 60911df907bc22fcb8c8af26cfc3f42412e94078 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Thu, 22 Mar 2018 11:22:16 -0700 Subject: [PATCH] Fix release packaging build (#6459) The release packaging build needs to have 'dotnet' in path, fixed that by adding Find-DotNet Refactored restore logic so it can be used from both Start-PSBuild and Copy-PSGalleryModules --- build.psm1 | 54 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/build.psm1 b/build.psm1 index 43d9363ce1..f261c938ec 100644 --- a/build.psm1 +++ b/build.psm1 @@ -525,21 +525,7 @@ Fix steps: } # handle Restore - if ($Restore -or -not (Test-Path "$($Options.Top)/obj/project.assets.json")) { - $srcProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen", "$PSScriptRoot/src/Modules") - - $RestoreArguments = @("--runtime",$Options.Runtime,"--verbosity") - if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) { - $RestoreArguments += "detailed" - } else { - $RestoreArguments += "quiet" - } - - $srcProjectDirs | ForEach-Object { - Write-Log "Run dotnet restore $_ $RestoreArguments" - Start-NativeExecution { dotnet restore $_ $RestoreArguments } - } - } + Restore-PSPackage -Options $Options -Force:$Restore # handle ResGen # Heuristic to run ResGen on the fresh machine @@ -641,6 +627,41 @@ Fix steps: } } +function Restore-PSPackage +{ + param( + [ValidateNotNullOrEmpty()] + [Parameter()] + [string[]] $ProjectDirs, + + [ValidateNotNullOrEmpty()] + [Parameter()] + $Options = (Get-PSOptions -DefaultToNew), + + [switch] $Force + ) + + if (-not $ProjectDirs) + { + $ProjectDirs = @($Options.Top, "$PSScriptRoot/src/TypeCatalogGen", "$PSScriptRoot/src/ResGen", "$PSScriptRoot/src/Modules") + } + + if ($Force -or (-not (Test-Path "$($Options.Top)/obj/project.assets.json"))) { + + $RestoreArguments = @("--runtime",$Options.Runtime,"--verbosity") + if ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent) { + $RestoreArguments += "detailed" + } else { + $RestoreArguments += "quiet" + } + + $ProjectDirs | ForEach-Object { + Write-Log "Run dotnet restore $_ $RestoreArguments" + Start-NativeExecution { dotnet restore $_ $RestoreArguments } + } + } +} + function Restore-PSModuleToBuild { param( @@ -2331,6 +2352,9 @@ function Copy-PSGalleryModules throw "Installing to an unexpected location" } + Find-DotNet + Restore-PSPackage + $cache = dotnet nuget locals global-packages -l if ($cache -match "info : global-packages: (.*)") { $nugetCache = $matches[1]