Skip to content

Commit bb4d8e9

Browse files
author
Maddie Clayton
authored
Merge pull request Azure#7146 from bganapa/publish-module-order
Deleting the matching downloaded module before publishing
2 parents 9d800f5 + 131a8ee commit bb4d8e9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tools/PublishModules.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,20 @@ function Add-Module {
670670
$moduleSourcePath = Join-Path -Path $Path -ChildPath $moduleManifest
671671
$file = Get-Item $moduleSourcePath
672672
Import-LocalizedData -BindingVariable ModuleMetadata -BaseDirectory $file.DirectoryName -FileName $file.Name
673+
674+
$moduleVersion = $ModuleMetadata.ModuleVersion.ToString()
675+
if ((!$IsNetCore) -and ($ModuleMetadata.PrivateData.PSData.Prerelease -ne $null)) {
676+
$moduleVersion += ("-" + $ModuleMetadata.PrivateData.PSData.Prerelease -replace "--", "-")
677+
}
673678

679+
if (Find-Module -Name $moduleName -Repository $TempRepo -RequiredVersion $moduleVersion -AllowPrerelease -ErrorAction SilentlyContinue)
680+
{
681+
Write-Output "Existing module found: $moduleName"
682+
$moduleNupkgPath = Join-Path -Path $TempRepoPath -ChildPath ($moduleName + "." + $moduleVersion + ".nupkg")
683+
Write-Output "Deleting the module: $moduleNupkgPath"
684+
Remove-Item -Path $moduleNupkgPath -Force
685+
}
686+
674687
Write-Output "Publishing the module $moduleName"
675688
Publish-Module -Path $Path -Repository $TempRepo -Force | Out-Null
676689
Write-Output "$moduleName published"
@@ -683,11 +696,6 @@ function Add-Module {
683696
}
684697
Write-Output "No root module found, creating"
685698

686-
$moduleVersion = $ModuleMetadata.ModuleVersion.ToString()
687-
if ((!$IsNetCore) -and ($ModuleMetadata.PrivateData.PSData.Prerelease -ne $null)) {
688-
$moduleVersion += ("-" + $ModuleMetadata.PrivateData.PSData.Prerelease -replace "--", "-")
689-
}
690-
691699
Write-Output "Changing to local repository directory for module modifications $TempRepoPath"
692700
Push-Location $TempRepoPath
693701

0 commit comments

Comments
 (0)