Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit 61f792c

Browse files
committed
address pr comments
1 parent 93a7bc7 commit 61f792c

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

src/PowerShellGet/private/functions/New-NugetPackage.ps1

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,15 @@ function New-NugetPackage {
9191
$process.Start() | Out-Null
9292
$process.WaitForExit()
9393

94+
if (Test-Path -Path $tempPath) {
95+
Remove-Item -Path $tempPath -Force -Recurse
96+
}
97+
9498
if (-Not ($process.ExitCode -eq 0 )) {
95-
if (Test-Path -Path $tempPath) {
96-
Remove-Item -Path $tempPath -Force -Recurse
97-
}
9899
$stdOut = $process.StandardOut.ReadToEnd()
99100
throw "dotnet cli failed to pack $stdOut"
100101
}
101102

102-
if (Test-Path -Path $tempPath) {
103-
Remove-Item -Path $tempPath -Force -Recurse
104-
}
105103
}
106104

107105
$stdOut = $process.StandardOutput.ReadLine()

src/PowerShellGet/private/functions/New-NuspecFile.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ function New-NuspecFile {
6262
$Tags = $Tags -Join " "
6363

6464
if ($Tags.Length -gt 4000) {
65-
$Tags = $Tags.Substring(0, $Tags.LastIndexOf(" "))
66-
Write-Warning -Message "Nuspec 'Tag' list exceeded max 4000 characters and was truncated."
65+
Write-Warning -Message "Tag list exceeded 4000 characters and may not be accepted by some Nuget feeds."
6766
}
6867

6968
$metaDataElementsHash = [ordered]@{
@@ -121,5 +120,8 @@ function New-NuspecFile {
121120

122121
$xml.AppendChild($packageElement) | Out-Null
123122

124-
$xml.save("$OutputPath\$Id.nuspec")
123+
$nuspecFullName = Join-Path -Path $OutputPath -ChildPath "$Id.nuspec"
124+
$xml.save($nuspecFullName)
125+
126+
Write-Output $nuspecFullName
125127
}

src/PowerShellGet/private/functions/Publish-PSArtifactUtility.ps1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,6 @@ function Publish-PSArtifactUtility {
342342
$VersionString = "$($Dependency.MinimumVersion)"
343343
}
344344

345-
# fix#335 refactor to construct object to pass to new New-NuspecFile function.
346345
$props = @{
347346
id = $ModuleName
348347
version = $VersionString
@@ -352,7 +351,6 @@ function Publish-PSArtifactUtility {
352351
$dependencies += $dependencyObject
353352
}
354353

355-
# fix#335 refactor to use new New-NuspecFile function.
356354
$params = @{
357355
OutputPath = $NugetPackageRoot
358356
Id = $Name
@@ -371,14 +369,12 @@ function Publish-PSArtifactUtility {
371369
}
372370

373371
try {
374-
New-NuspecFile $params
375-
$NuspecFullName = Join-Path -Path $NugetPackageRoot -ChildPath "$Name.nuspec"
372+
$NuspecFullName = New-NuspecFile $params
376373
}
377374
catch {
378375
Write-Error -Message "Failed to create nuspec file $_.Exception" -ErrorAction Stop
379376
}
380377

381-
# fix#335 Refactor to use new New-NugetPackage function.
382378
try {
383379
if ($DotnetCommandPath) {
384380
New-NugetPackage -NuspecPath $NuspecFullName -NugetPackageRoot $NugetPackageRoot -UseDotnetCli -Verbose:$VerbosePreference
@@ -403,7 +399,6 @@ function Publish-PSArtifactUtility {
403399
Write-Error -Message $message -ErrorId $errorId -Category InvalidOperation -ErrorAction Stop
404400
}
405401

406-
# Fix#335 refactor to use new Publish-NugetPackage function.
407402
try {
408403
if ($DotnetCommandPath) {
409404
Publish-NugetPackage -NupkgPath $NupkgFullName -Destination $Destination -NugetApiKey $NugetApiKey -UseDotnetCli -Verbose:$VerbosePreference

0 commit comments

Comments
 (0)