Skip to content

Commit 1bf23d2

Browse files
committed
fix module publish issue
1 parent 5c76be7 commit 1bf23d2

File tree

3 files changed

+43
-23
lines changed

3 files changed

+43
-23
lines changed

build.proj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
<SetupOutputDirectory>$(PublishDirectory)\Setup</SetupOutputDirectory>
3737
<TestOutputDirectory>$(PublishDirectory)\TestResults</TestOutputDirectory>
3838
<BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
39-
<NuGetPublishingSource Condition=" '$(NuGetPublishingSource)' != '' ">http://psget/PSGallery/api/v2/</NuGetPublishingSource>
39+
<NuGetPublishingSource Condition=" '$(NuGetPublishingSource)' == '' ">http://psget/PSGallery/api/v2/</NuGetPublishingSource>
4040
</PropertyGroup>
4141
<ItemGroup>
4242
<CmdletSolutionsToBuild Include=".\src\ResourceManager\**\*.sln;.\src\ServiceManagement\ServiceManagement.sln" Condition=" '$(Scope)' == '' "/>
@@ -285,7 +285,7 @@
285285
<Error Condition=" '$(NuGetKey)' == '' " Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
286286
<Message Importance="high" Text="Publishing Cmdlets..." />
287287

288-
<Exec Command="$(PowerShellCommand) -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\PublishModules.ps1 $(Configuration) $(NuGetKey) \&quot;$(NuGetPublishingSource)\&quot;&quot;"/>
288+
<Exec Command="$(PowerShellCommand) -NoLogo -NoProfile -Command &quot;. $(LibraryToolsFolder)\PublishModules.ps1 $(Configuration) $(Scope) $(NuGetKey) \&quot;$(NuGetPublishingSource)\&quot; &quot;"/>
289289
</Target>
290290

291291
<PropertyGroup>
File renamed without changes.

tools/PublishModules.ps1

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@ param(
1616
[Parameter(Mandatory = $false, Position = 0)]
1717
[string] $buildConfig,
1818
[Parameter(Mandatory = $false, Position = 1)]
19-
[string] $apiKey,
19+
[string] $scope,
2020
[Parameter(Mandatory = $false, Position = 2)]
21+
[string] $apiKey,
22+
[Parameter(Mandatory = $false, Position = 3)]
2123
[string] $repositoryLocation
2224
)
2325

@@ -29,11 +31,17 @@ if ([string]::IsNullOrEmpty($buildConfig))
2931

3032
if ([string]::IsNullOrEmpty($repositoryLocation))
3133
{
32-
Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'"
33-
34+
Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'"
3435
$repositoryLocation = "https://dtlgalleryint.cloudapp.net/api/v2"
3536
}
3637

38+
if ([string]::IsNullOrEmpty($scope))
39+
{
40+
Write-Verbose "Default scope to all"
41+
$scope = 'all'
42+
}
43+
44+
Write-Host "Publishing $scope package(s)"
3745

3846
$packageFolder = "$PSScriptRoot\..\src\Package"
3947

@@ -44,27 +52,39 @@ if ($repo -ne $null) {
4452
$repoName = $(New-Guid).ToString()
4553
Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted
4654
}
47-
$modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure"
48-
# Publish Azure module
49-
Write-Host "Publishing Azure module from $modulePath"
50-
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
51-
# Publish AzureRM module
52-
$modulePath = "$PSScriptRoot\AzureRM"
53-
Write-Host "Publishing AzureRM module from $modulePath"
54-
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
55-
Write-Host "Published Azure module"
56-
# Publish AzureRM.Profile module
57-
Write-Host "Publishing AzureRM.Profile module from $modulePath"
58-
Publish-Module -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager\AzureRM.Profile" -NuGetApiKey $apiKey -Repository $repoName
59-
Write-Host "Published AzureRM.Profile module"
6055

61-
# Publish AzureRM modules
62-
$resourceManagerModules = Get-ChildItem -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager" -Directory
63-
foreach ($module in $resourceManagerModules) {
64-
if ($module -ne "AzureRM.Profile") {
56+
if (($scope -eq 'all') -or ($scope -eq 'servicemanagement')) {
57+
$modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure"
58+
# Publish Azure module
59+
Write-Host "Publishing Azure module from $modulePath"
60+
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
61+
}
62+
63+
if ($scope -eq 'AzureRM') {
64+
# Publish AzureRM module
65+
$modulePath = "$PSScriptRoot\AzureRM"
66+
Write-Host "Publishing AzureRM module from $modulePath"
67+
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
68+
Write-Host "Published Azure module"
69+
}
70+
71+
$resourceManagerRootFolder = "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager"
72+
$resourceManagerModules = Get-ChildItem -Path $resourceManagerRootFolder -Directory
73+
if ($scope -eq 'all') {
74+
# Publish AzureRM modules
75+
foreach ($module in $resourceManagerModules) {
6576
$modulePath = $module.FullName
6677
Write-Host "Publishing $module module from $modulePath"
67-
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
78+
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
6879
Write-Host "Published $module module"
6980
}
81+
} else {
82+
$modulePath = Join-Path $resourceManagerRootFolder "AzureRM.$scope"
83+
if (Test-Path $modulePath) {
84+
Write-Host "Publishing $scope module from $modulePath"
85+
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
86+
Write-Host "Published $scope module"
87+
} else {
88+
Write-Error "Can not find module with name $scope to publish"
89+
}
7090
}

0 commit comments

Comments
 (0)