From 8852891ad9a9cfaf054c7efc576053a723e99f88 Mon Sep 17 00:00:00 2001 From: Jonathan Myers Date: Tue, 13 Dec 2016 13:19:27 -0800 Subject: [PATCH] Ignore configurationToPack if it is literally $(BuildConfiguration) --- Tasks/NugetPackager/NuGetPackager.ps1 | 24 ++++++++++++++++++++---- Tasks/NugetPackager/task.json | 2 +- Tasks/NugetPackager/task.loc.json | 2 +- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Tasks/NugetPackager/NuGetPackager.ps1 b/Tasks/NugetPackager/NuGetPackager.ps1 index df739d876fc2..0d5d0ed89461 100644 --- a/Tasks/NugetPackager/NuGetPackager.ps1 +++ b/Tasks/NugetPackager/NuGetPackager.ps1 @@ -164,6 +164,22 @@ if (-not $nuGetPath) throw (Get-LocalizedString -Key "Unable to locate {0}" -ArgumentList 'nuget.exe') } +$allBuildProps = @() + +# We set the default to $(BuildConfiguration) so the task works by default with the Visual +# Studio Build / MSBuild template. Unfortunately, that causes it to *not* work by default +# with the empty build template, so we just ignore the value if it wasn't substituted with +# something useful. +if($configurationToPack -and $configurationToPack -ne '$(BuildConfiguration)') +{ + $allBuildProps += @("Configuration=$configurationToPack") +} + +if ($buildProperties) +{ + $allBuildProps += @($buildProperties -split ";") +} + $initialNuGetExtensionsPath = $env:NUGET_EXTENSIONS_PATH try { @@ -187,12 +203,12 @@ try $slnFolder = $(Get-ItemProperty -Path $fileToPackage -Name 'DirectoryName').DirectoryName #Setup Nuget - $buildProps = "Configuration=$configurationToPack"; - if ([string]::IsNullOrEmpty($buildProperties) -eq $false) + $argsPack = "pack `"$fileToPackage`" -OutputDirectory `"$outputdir`"" + + if ($allBuildProps) { - $buildProps = ($buildProps + ";" + $buildProperties) + $argsPack += " -Properties $($allBuildProps -join ";")" } - $argsPack = "pack `"$fileToPackage`" -OutputDirectory `"$outputdir`" -Properties $buildProps"; if($b_includeReferencedProjects) { diff --git a/Tasks/NugetPackager/task.json b/Tasks/NugetPackager/task.json index f4d890b09d43..c40be2b4ab15 100644 --- a/Tasks/NugetPackager/task.json +++ b/Tasks/NugetPackager/task.json @@ -9,7 +9,7 @@ "version": { "Major": 0, "Minor": 1, - "Patch": 69 + "Patch": 70 }, "demands": [ "Cmd" diff --git a/Tasks/NugetPackager/task.loc.json b/Tasks/NugetPackager/task.loc.json index 566fe05cca76..12d2a8038d12 100644 --- a/Tasks/NugetPackager/task.loc.json +++ b/Tasks/NugetPackager/task.loc.json @@ -9,7 +9,7 @@ "version": { "Major": 0, "Minor": 1, - "Patch": 69 + "Patch": 70 }, "demands": [ "Cmd"