forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublishToolsModule.ps1
35 lines (29 loc) · 1.02 KB
/
PublishToolsModule.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<#
.SYNOPSIS
Create nuget packages for module.
.PARAMETER ModuleName
Module Name to publish.
.PARAMETER RepositoryLocation
Location we want to publish too.
#>
param(
[Parameter(Mandatory = $true)]
[string]$ModuleName,
[Parameter(Mandatory = $true)]
[string]$RepositoryLocation,
[Parameter(Mandatory = $true)]
[string]$PublishLocation
)
Import-Module "$PSScriptRoot\PublishModules.psm1"
try {
$tempRepoName = ([System.Guid]::NewGuid()).ToString()
Register-PSRepository -Name $tempRepoName -SourceLocation $RepositoryLocation -PublishLocation $PublishLocation -InstallationPolicy Trusted -PackageManagementProvider NuGet
$modulePath = Join-Path $RepositoryLocation $ModuleName -Resolve
Save-PackagesFromPsGallery -TempRepo $tempRepoName -TempRepoPath $RepositoryLocation -ModulePaths $modulePath
Publish-Module -Path $modulePath -Repository $tempRepoName -Force
} catch {
$Errors = $_
Write-Error ($_ | Out-String)
} finally {
Unregister-PSRepository -Name $tempRepoName
}