Skip to content

Commit 42d311c

Browse files
committed
Merge pull request #978 from stankovski/dev
MSI installer for PowerShell Gallery
2 parents 72e481d + 44704ab commit 42d311c

File tree

3 files changed

+94
-52
lines changed

3 files changed

+94
-52
lines changed

setup-powershellget/Setup/ShortcutStartup.ps1

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,25 @@ Finalizing installation of Azure PowerShell.
2626
Installing Azure Modules from PowerShell Gallery.
2727
This may take some time...
2828
"@
29+
$env:PSModulePath = "$env:HOME\Documents\WindowsPowerShell\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules\"
30+
2931
Import-Module PackageManagement
30-
Get-PackageProvider -Name NuGet -ForceBootstrap
32+
33+
$result = Get-PackageProvider -Name NuGet -ForceBootstrap
34+
35+
Import-Module PowerShellGet
3136

32-
$NuGetPublishingSource = $env:NuGetPublishingSource
33-
if ([string]::IsNullOrWhiteSpace($NuGetPublishingSource)) {
34-
Install-Module AzureRM -Repository $NuGetPublishingSource
35-
} else {
36-
Install-Module AzureRM
37-
}
37+
Install-Module AzureRM
38+
Write-Output "AzureRM $((Get-InstalledModule -Name AzureRM)[0].Version) installed..."
39+
Update-AzureRM
3840
} else {
3941
cd c:\
4042
$welcomeMessage = @"
4143
For a list of all Azure cmdlets type 'help azure'.
4244
For a list of Azure Pack cmdlets type 'Get-Command *wapack*'.
45+
46+
To use Azure Service Management cmdlets please execute the following cmdlet:
47+
Install-Module Azure
4348
"@
4449
Write-Output $welcomeMessage
4550

tools/AzureRM/AzureRM.psm1

Lines changed: 56 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
$AzureRMModules = @{
2+
"Azure.Storage" = "0.9.8";
3+
"AzureRM.ApiManagement" = "0.9.8";
4+
"AzureRM.Automation" = "0.9.8";
5+
"AzureRM.Backup" = "0.9.8";
6+
"AzureRM.Batch" = "0.9.8";
7+
"AzureRM.Compute" = "0.9.8";
8+
"AzureRM.DataFactories" = "0.9.8";
9+
"AzureRM.Dns" = "0.9.8";
10+
"AzureRM.HDInsight" = "0.9.8";
11+
"AzureRM.Insights" = "0.9.8";
12+
"AzureRM.KeyVault" = "0.9.8";
13+
"AzureRM.Network" = "0.9.8";
14+
"AzureRM.OperationalInsights" = "0.9.8";
15+
"AzureRM.Profile" = "0.9.8";
16+
"AzureRM.RedisCache" = "0.9.8";
17+
"AzureRM.Resources" = "0.9.8";
18+
"AzureRM.SiteRecovery" = "0.9.8";
19+
"AzureRM.Sql" = "0.9.8";
20+
"AzureRM.Storage" = "0.9.8";
21+
"AzureRM.StreamAnalytics" = "0.9.8";
22+
"AzureRM.Tags" = "0.9.8";
23+
"AzureRM.TrafficManager" = "0.9.8";
24+
"AzureRM.UsageAggregates" = "0.9.8";
25+
"AzureRM.Websites" = "0.9.8"
26+
}
27+
128
<#
229
.Synopsis
330
Install Azure Resource Manager cmdlet modules
@@ -13,36 +40,36 @@
1340
#>
1441
function Update-AzureRM
1542
{
16-
param(
17-
[Parameter(Position=0, Mandatory = $false)]
18-
[string]
19-
$Repository,
20-
21-
[Parameter(Position=1, Mandatory = $false)]
22-
[ValidateSet("CurrentUser","AllUsers")]
23-
[string]
24-
$Scope)
43+
param(
44+
[Parameter(Position=0; Mandatory = $false)]
45+
[string]
46+
$Repository;
2547

26-
if ([string]::IsNullOrWhiteSpace($Scope))
27-
{
28-
$Scope = "AllUsers"
29-
}
48+
[Parameter(Position=1; Mandatory = $false)]
49+
[ValidateSet("CurrentUser";"AllUsers")]
50+
[string]
51+
$Scope)
3052

31-
Install-Module AzureRM.Profile -Repository $Repository
32-
if ([string]::IsNullOrWhiteSpace($Repository))
33-
{
34-
$modules = Find-Module -Name AzureRM.* | Where-Object {$_.Name -ne "AzureRM" -and $_.Name -ne "AzureRM.Profile"}
35-
} else {
36-
$modules = Find-Module -Repository $Repository | Where-Object {$_.Name -like "AzureRM.*" -and $_.Name -ne "AzureRM" -and $_.Name -ne "AzureRM.Profile"}
37-
}
53+
if ([string]::IsNullOrWhiteSpace($Scope))
54+
{
55+
$Scope = "AllUsers"
56+
}
3857

39-
Write-Output "Installing $($modules.Length) AzureRM modules. This may take a few minutes."
58+
Write-Output "Installing AzureRM modules."
4059

41-
$result = $modules | ForEach {
42-
Start-Job -Name $_.Name -ScriptBlock {
43-
Install-Module -Name $args[0] -Repository $args[1] -Scope $args[2]
44-
Write-Output "$($args[0]) installed..."
45-
} -ArgumentList $_.Name, $Repository, $Scope }
46-
47-
$modules | ForEach {Get-Job -Name $_.Name | Wait-Job | Receive-Job }
48-
}
60+
$result = $AzureRMModules | ForEach {
61+
Start-Job -Name $_ -ScriptBlock {
62+
if ([string]::IsNullOrWhiteSpace($args[1]))
63+
{
64+
Install-Module -Name $args[0] -Scope $args[2]
65+
} else {
66+
Install-Module -Name $args[0] -Repository $args[1] -Scope $args[2]
67+
}
68+
$v = (Get-InstalledModule -Name $args[0])[0].Version.ToString()
69+
Write-Output "$($args[0]) $v installed..."
70+
} -ArgumentList $_; $Repository; $Scope }
71+
72+
$AzureRMModules | ForEach {Get-Job -Name $_ | Wait-Job | Receive-Job }
73+
}
74+
New-Alias -Name Install-AzureRM -Value Update-AzureRM
75+
Export-ModuleMember -function * -Alias *

tools/PublishModules.ps1

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,43 @@
1515
param(
1616
[Parameter(Mandatory = $false, Position = 0)]
1717
[string] $buildConfig,
18-
[Parameter(Mandatory = $false, Position = 1)]
18+
[Parameter(Mandatory = $false, Position = 1)]
1919
[string] $apiKey,
20-
[Parameter(Mandatory = $false, Position = 2)]
20+
[Parameter(Mandatory = $false, Position = 2)]
2121
[string] $repositoryLocation
2222
)
2323

2424
if ([string]::IsNullOrEmpty($buildConfig))
2525
{
26-
Write-Verbose "Setting build configuration to 'Release'"
27-
$buildConfig = 'Release'
26+
Write-Verbose "Setting build configuration to 'Release'"
27+
$buildConfig = "Release"
2828
}
2929

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

37+
3638
$packageFolder = "$PSScriptRoot\..\src\Package"
3739

38-
$repoName = $(New-Guid).ToString()
39-
Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation -InstallationPolicy Trusted
40+
$repo = Get-PSRepository | where { $_.SourceLocation -eq $repositoryLocation }
41+
if ($repo -ne $null) {
42+
$repoName = $repo.Name
43+
} else {
44+
$repoName = $(New-Guid).ToString()
45+
Register-PSRepository -Name $repoName -SourceLocation $repositoryLocation -PublishLocation $repositoryLocation/package -InstallationPolicy Trusted
46+
}
4047
$modulePath = "$packageFolder\$buildConfig\ServiceManagement\Azure"
4148
# Publish Azure module
4249
Write-Host "Publishing Azure module from $modulePath"
43-
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
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")
4455
Write-Host "Published Azure module"
4556
# Publish AzureRM.Profile module
4657
Write-Host "Publishing AzureRM.Profile module from $modulePath"
@@ -50,11 +61,10 @@ Write-Host "Published AzureRM.Profile module"
5061
# Publish AzureRM modules
5162
$resourceManagerModules = Get-ChildItem -Path "$packageFolder\$buildConfig\ResourceManager\AzureResourceManager" -Directory
5263
foreach ($module in $resourceManagerModules) {
53-
if ($module -ne "AzureRM.Profile") {
54-
$modulePath = $module.FullName
55-
Write-Host "Publishing $module module from $modulePath"
56-
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName
57-
Write-Host "Published $module module"
58-
}
64+
if ($module -ne "AzureRM.Profile") {
65+
$modulePath = $module.FullName
66+
Write-Host "Publishing $module module from $modulePath"
67+
Publish-Module -Path $modulePath -NuGetApiKey $apiKey -Repository $repoName -Tags ("Azure", "AzureRM")
68+
Write-Host "Published $module module"
69+
}
5970
}
60-
Unregister-PSRepository -Name $repoName

0 commit comments

Comments
 (0)