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
This commit is contained in:
Aditya Patwardhan
2018-03-22 11:37:54 -07:00
parent e5046baf9d
commit 60911df907
+39 -15
View File
@@ -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]