Skip to content

Commit 091e7f9

Browse files
committed
Adding more logging in publish module. Adding null check for unregistering Repositories at the end of PublishModule
1 parent 3cf8f72 commit 091e7f9

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

tools/PublishModules.ps1

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function Make-StrictModuleDependencies
101101

102102
if ($newModules.Count -gt 0)
103103
{
104-
Update-ModuleManifest -Path $Path -RequiredModules $newModules -LicenseUri "http://aka.ms/azps-license"
104+
Update-ModuleManifest -Path $Path -RequiredModules $newModules
105105
}
106106

107107
}
@@ -190,8 +190,7 @@ function Change-RMModule
190190
$moduleSourcePath = Join-Path -Path $Path -ChildPath $moduleManifest
191191
$manifest = Make-StrictModuleDependencies $moduleSourcePath
192192
$manifest = Test-ModuleManifest -Path $moduleSourcePath
193-
$toss = Publish-Module -Path $Path -Repository $TempRepo -LicenseUri "http://aka.ms/azps-license"
194-
#'$nugetExe pack'
193+
$toss = Publish-Module -Path $Path -Repository $TempRepo
195194
Write-Output "Changing to directory for module modifications $TempRepoPath"
196195
pushd $TempRepoPath
197196
try
@@ -264,13 +263,13 @@ if ([string]::IsNullOrEmpty($buildConfig))
264263

265264
if ([string]::IsNullOrEmpty($repositoryLocation))
266265
{
267-
Write-Verbose "No repository location was provided, setting it to default"
268-
Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'"
266+
Write-Output "No repository location was provided, setting it to default"
267+
Write-Output "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'"
269268
$repositoryLocation = "https://dtlgalleryint.cloudapp.net/api/v2"
270269
}
271270
else
272271
{
273-
Write-Verbose "Setting repository location to '$repositoryLocation'"
272+
Write-Output "Setting repository location to '$repositoryLocation'"
274273
}
275274

276275
if ([string]::IsNullOrEmpty($scope))
@@ -293,25 +292,25 @@ $repo = Get-PSRepository | where { $_.SourceLocation -eq $repositoryLocation }
293292
if ($repo -ne $null)
294293
{
295294
$repoName = $repo.Name
296-
Write-Verbose "Existing PS Repository detected: $repo.Name"
295+
Write-Output "Existing PS Repository detected: $repo.Name"
297296
}
298297
else
299298
{
300299
$repoName = $(New-Guid).ToString()
301-
Write-Verbose "Setting up new PS Repository to: -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted"
300+
Write-Output "Setting up new PS Repository to: -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted"
302301
Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation\package -InstallationPolicy Trusted
303302
}
304303

305304
$publishToLocal = test-path $repositoryLocation
306305
[string]$tempRepoPath = "$PSScriptRoot\..\src\package"
307306
if ($publishToLocal)
308307
{
309-
Write-Verbose "Publish to local is set to: $publishToLocal"
308+
Write-Output "Publish to local is set to: $publishToLocal"
310309
$tempRepoPath = (Join-Path $repositoryLocation -ChildPath "package")
311310
}
312311

313312
$tempRepoName = ([System.Guid]::NewGuid()).ToString()
314-
Write-Verbose "Setting up TEMP PS Repository to: -Name $tempRepoName -SourceLocation $tempRepoPath -PublishLocation $tempRepoPath -InstallationPolicy Trusted -PackageManagementProvider NuGet"
313+
Write-Output "Setting up TEMP PS Repository to: -Name $tempRepoName -SourceLocation $tempRepoPath -PublishLocation $tempRepoPath -InstallationPolicy Trusted -PackageManagementProvider NuGet"
315314
Register-PSRepository -Name $tempRepoName -SourceLocation $tempRepoPath -PublishLocation $tempRepoPath -InstallationPolicy Trusted -PackageManagementProvider NuGet
316315

317316
try {
@@ -340,6 +339,16 @@ try {
340339
}
341340
finally
342341
{
343-
Unregister-PSRepository -Name $tempRepoName
344-
Unregister-PSRepository -Name $repoName
342+
if($tempRepoName -ne $null)
343+
{
344+
Write-Output "Unregistering Repository: $tempRepoName"
345+
Get-PSRepository -Name $tempRepoName | Unregister-PSRepository
346+
}
347+
348+
if($repoName -ne $null)
349+
{
350+
Write-Output "Unregistering Repository: $repoName"
351+
Get-PSRepository -Name $repoName | Unregister-PSRepository
352+
}
353+
345354
}

0 commit comments

Comments
 (0)