From 4c33b06570c412fe75c0da62455b2d7ba5957ca4 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 20 Mar 2020 10:12:58 -0700 Subject: [PATCH] Ensure pack-module.ps1 exists before packing modules. --- tools/PackModule.ps1 | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tools/PackModule.ps1 b/tools/PackModule.ps1 index cc4edd375ac..449199eb246 100644 --- a/tools/PackModule.ps1 +++ b/tools/PackModule.ps1 @@ -17,24 +17,26 @@ if($PSCmdlet.ParameterSetName -eq "GraphResource"){ } $PackModulePS1 = Join-Path $ModuleProjLocation "/pack-module.ps1" -# Pack module -& $PackModulePS1 -if($LASTEXITCODE) { - Write-Error "Failed to pack '$Module' module." -} +if (Test-Path $PackModulePS1) { + # Pack module + & $PackModulePS1 + if($LASTEXITCODE) { + Write-Error "Failed to pack '$Module' module." + } -# Get generated .nupkg -$NuGetPackage = (Get-ChildItem (Join-Path $ModuleProjLocation "./bin") | Where-Object Name -Match ".nupkg").FullName + # Get generated .nupkg + $NuGetPackage = (Get-ChildItem (Join-Path $ModuleProjLocation "./bin") | Where-Object Name -Match ".nupkg").FullName -$ModuleArtifactLocation = "$ArtifactsLocation\$Module" -if(-not (Test-Path $ModuleArtifactLocation)) { - New-Item -Path $ModuleArtifactLocation -Type Directory -} else { - Remove-Item -Path "$ModuleArtifactLocation\*" -Recurse -Force -} + $ModuleArtifactLocation = "$ArtifactsLocation\$Module" + if(-not (Test-Path $ModuleArtifactLocation)) { + New-Item -Path $ModuleArtifactLocation -Type Directory + } else { + Remove-Item -Path "$ModuleArtifactLocation\*" -Recurse -Force + } -# Copy package to artifacts folder. -Write-Host -ForegroundColor Green "Copying '$NuGetPackage' to $ModuleArtifactLocation..." -Copy-Item -Path $NuGetPackage -Destination $ModuleArtifactLocation -Force + # Copy package to artifacts folder. + Write-Host -ForegroundColor Green "Copying '$NuGetPackage' to $ModuleArtifactLocation..." + Copy-Item -Path $NuGetPackage -Destination $ModuleArtifactLocation -Force -Write-Host -ForegroundColor Green "-------------Done-------------" \ No newline at end of file + Write-Host -ForegroundColor Green "-------------Done-------------" +} \ No newline at end of file