Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<SetupOutputDirectory>$(PublishDirectory)\Setup</SetupOutputDirectory>
<TestOutputDirectory>$(PublishDirectory)\TestResults</TestOutputDirectory>
<BuildInParallel Condition="'$(BuildInParallel)' == ''">true</BuildInParallel>
<NuGetPublishingSource Condition=" '$(NuGetPublishingSource)' != '' ">http://psget/PSGallery/api/v2/</NuGetPublishingSource>
<NuGetPublishingSource Condition=" '$(NuGetPublishingSource)' == '' ">http://psget/PSGallery/api/v2/</NuGetPublishingSource>
</PropertyGroup>
<ItemGroup>
<CmdletSolutionsToBuild Include=".\src\ResourceManager\**\*.sln;.\src\ServiceManagement\ServiceManagement.sln" Condition=" '$(Scope)' == '' "/>
Expand Down Expand Up @@ -285,7 +285,7 @@
<Error Condition=" '$(NuGetKey)' == '' " Text="You must provide the NuGetKey parameter to the build: /p:NuGetKey=YOUR_PUBLISHING_KEY" />
<Message Importance="high" Text="Publishing Cmdlets..." />

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

<PropertyGroup>
Expand Down
File renamed without changes.
62 changes: 41 additions & 21 deletions tools/PublishModules.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ param(
[Parameter(Mandatory = $false, Position = 0)]
[string] $buildConfig,
[Parameter(Mandatory = $false, Position = 1)]
[string] $apiKey,
[string] $scope,
[Parameter(Mandatory = $false, Position = 2)]
[string] $apiKey,
[Parameter(Mandatory = $false, Position = 3)]
[string] $repositoryLocation
)

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

if ([string]::IsNullOrEmpty($repositoryLocation))
{
Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'"

Write-Verbose "Setting repository location to 'https://dtlgalleryint.cloudapp.net/api/v2'"
$repositoryLocation = "https://dtlgalleryint.cloudapp.net/api/v2"
}

if ([string]::IsNullOrEmpty($scope))
{
Write-Verbose "Default scope to all"
$scope = 'all'
}

Write-Host "Publishing $scope package(s)"

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

Expand All @@ -44,27 +52,39 @@ if ($repo -ne $null) {
$repoName = $(New-Guid).ToString()
Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted
}
$modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure"
# Publish Azure module
Write-Host "Publishing Azure module from $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
# Publish AzureRM module
$modulePath = "$PSScriptRoot\AzureRM"
Write-Host "Publishing AzureRM module from $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
Write-Host "Published Azure module"
# Publish AzureRM.Profile module
Write-Host "Publishing AzureRM.Profile module from $modulePath"
Publish-Module -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager\AzureRM.Profile" -NuGetApiKey $apiKey -Repository $repoName
Write-Host "Published AzureRM.Profile module"

# Publish AzureRM modules
$resourceManagerModules = Get-ChildItem -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager" -Directory
foreach ($module in $resourceManagerModules) {
if ($module -ne "AzureRM.Profile") {
if (($scope -eq 'all') -or ($scope -eq 'servicemanagement')) {
$modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure"
# Publish Azure module
Write-Host "Publishing Azure module from $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
}

if ($scope -eq 'AzureRM') {
# Publish AzureRM module
$modulePath = "$PSScriptRoot\AzureRM"
Write-Host "Publishing AzureRM module from $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
Write-Host "Published Azure module"
}

$resourceManagerRootFolder = "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager"
$resourceManagerModules = Get-ChildItem -Path $resourceManagerRootFolder -Directory
if ($scope -eq 'all') {
# Publish AzureRM modules
foreach ($module in $resourceManagerModules) {
$modulePath = $module.FullName
Write-Host "Publishing $module module from $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
Write-Host "Published $module module"
}
} else {
$modulePath = Join-Path $resourceManagerRootFolder "AzureRM.$scope"
if (Test-Path $modulePath) {
Write-Host "Publishing $scope module from $modulePath"
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
Write-Host "Published $scope module"
} else {
Write-Error "Can not find module with name $scope to publish"
}
}