Skip to content

Commit

Permalink
Update package script to support requiredmodule (#13424)
Browse files Browse the repository at this point in the history
  • Loading branch information
dingmeng-xue authored Nov 6, 2020
1 parent 5c27eb4 commit fbd0b9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tools/Az.Tools.Predictor/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@

<Target Name="Package" Condition="'$(Configuration)' == 'Release'">
<Message Text="Package $(ModuleName)" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)/PublishToolsModule.ps1 -RepositoryLocation $(ArtifactFolder) -ModuleName $(ModuleName)&quot;" />
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)/PublishToolsModule.ps1 -RepositoryLocation $(ArtifactFolder) -PublishLocation $(ArtifactFolder) -ModuleName $(ModuleName)&quot;" />
</Target>
</Project>
13 changes: 11 additions & 2 deletions tools/PublishToolsModule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,21 @@ param(
[string]$ModuleName,

[Parameter(Mandatory = $true)]
[string]$RepositoryLocation
[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 $RepositoryLocation -InstallationPolicy Trusted -PackageManagementProvider NuGet
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 = $_
Expand Down

0 comments on commit fbd0b9b

Please sign in to comment.