Skip to content

Commit 4708975

Browse files
msJinLeiVeryEarlydingmeng-xue
authored
Initial Version of Az.Tools.Installer (#13091)
* psd1 & psm1 of Az.Installer with a demo cmdlet (#12698) * Internal/az.installer (#12817) * add util functions * add install-azmodule * add log to cmdlets * move verbose messages to debug * move under tools\ * polish warning message * move install-azmodule to exports * export install-azmodule * rename to az.tools.installer * Internal/az.installer (#12860) * add util functions * add install-azmodule * add log to cmdlets * move verbose messages to debug * move under tools\ * polish warning message * move install-azmodule to exports * export install-azmodule * rename to az.tools.installer * add uninstall-AzModule * Cmdlet Update-AzModule (#12832) * Update-AzModule * Address to PM requirements 1. Remove prefix Az. when input module name 2. update calculate from most recently installed respositories of different modules 3. reorder the sequence of module udpate and uninstall 4. other bug fix * Add telemetry * Support telemetry * Move Get-AzModuleUpdateList to internal (#12865) * add telemetry to Uninstall-AzModule cmdlet * bugfix: module name was not handled properly * Add environment variable to disable telemetry * parallel executing Install/Uninstall module * update code after review * improve performance * Fix Update-AzModule issues * bug fix * remove unused util * remove az.accounts when allow preview * Fix issue when no module to udpate * Add sign pipeline * skip confirmation when remove-job * remove debug info * fix parameter reference * filter installedmodules before uninstall * bugfix for uninstall * Add synopsis and example to exported cmdlets * add default parameter set for uninstall-azmodule * add input validatin * remove unnecessary warning message * Fix bugs for Update-AzModule * Add autocompleter of Repository for Uninstall-AzModule * Update help of Update-AzModule Co-authored-by: Yabo Hu <[email protected]> Co-authored-by: dingmeng-xue <[email protected]>
1 parent c32ab4c commit 4708975

14 files changed

+1324
-0
lines changed

.azure-pipelines/sign-tools.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
trigger: none
2+
pr: none
3+
4+
pool:
5+
vmImage: 'windows-2019'
6+
7+
steps:
8+
- task: PowerShell@2
9+
displayName: 'Install platyPS'
10+
inputs:
11+
targetType: inline
12+
script: 'Install-Module platyPS -Force -Confirm:$false -Scope CurrentUser'
13+
14+
- task: PowerShell@2
15+
displayName: 'Install PowerShellGet [v2.1.3 has a Publish-Module bug]'
16+
inputs:
17+
targetType: inline
18+
script: 'Install-Module PowerShellGet -Force -Confirm:$false -Scope CurrentUser -SkipPublisherCheck'
19+
20+
- task: DotNetCoreCLI@2
21+
displayName: 'Build'
22+
inputs:
23+
command: custom
24+
custom: msbuild
25+
arguments: 'tools\Az.Tools.Installer\build.proj /t:Build'
26+
27+
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
28+
displayName: 'Signing'
29+
inputs:
30+
ConnectedServiceName: $(signServiceConnection)
31+
FolderPath: artifacts
32+
Pattern: |
33+
Tools/**/*.ps1
34+
Tools/**/*.psd1
35+
Tools/**/*.psm1
36+
Tools/**/*.ps1xml
37+
UseMinimatch: true
38+
signConfigType: inlineSignParams
39+
inlineOperation: |
40+
[
41+
{
42+
"KeyCode": "CP-230012",
43+
"OperationCode": "SigntoolSign",
44+
"Parameters": {
45+
"OpusName": "Microsoft",
46+
"OpusInfo": "http://www.microsoft.com",
47+
"FileDigest": "/fd \"SHA256\"",
48+
"PageHash": "/NPH",
49+
"TimeStamp": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
50+
},
51+
"ToolName": "sign",
52+
"ToolVersion": "1.0"
53+
},
54+
{
55+
"KeyCode": "CP-230012",
56+
"OperationCode": "SigntoolVerify",
57+
"Parameters": {},
58+
"ToolName": "sign",
59+
"ToolVersion": "1.0"
60+
}
61+
]
62+
63+
- task: DotNetCoreCLI@2
64+
displayName: Package
65+
inputs:
66+
command: custom
67+
custom: msbuild
68+
arguments: 'tools\Az.Tools.Installer\build.proj /t:Package'
69+
70+
- task: PublishPipelineArtifact@0
71+
displayName: 'Save artifacts'
72+
inputs:
73+
artifactName: artifacts
74+
targetPath: artifacts
75+
condition: succeededOrFailed()
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#
2+
# Module manifest for module 'Az.Tools.Installer'
3+
#
4+
# Generated by: Microsoft Corporation
5+
#
6+
# Generated on: 8/19/2020
7+
#
8+
9+
@{
10+
11+
# Script module or binary module file associated with this manifest.
12+
RootModule = 'Az.Tools.Installer.psm1'
13+
14+
# Version number of this module.
15+
ModuleVersion = '0.1.0'
16+
17+
# Supported PSEditions
18+
CompatiblePSEditions = 'Core', 'Desktop'
19+
20+
# ID used to uniquely identify this module
21+
GUID = '8c7c6fcd-a96f-460b-89e2-ff822a3246c8'
22+
23+
# Author of this module
24+
Author = 'Microsoft Corporation'
25+
26+
# Company or vendor of this module
27+
CompanyName = 'Microsoft Corporation'
28+
29+
# Copyright statement for this module
30+
Copyright = 'Microsoft Corporation. All rights reserved.'
31+
32+
# Description of the functionality provided by this module
33+
Description = 'Microsoft Azure PowerShell Module Management.'
34+
35+
# Minimum version of the PowerShell engine required by this module
36+
PowerShellVersion = '5.1'
37+
38+
# Name of the PowerShell host required by this module
39+
# PowerShellHostName = ''
40+
41+
# Minimum version of the PowerShell host required by this module
42+
# PowerShellHostVersion = ''
43+
44+
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
45+
DotNetFrameworkVersion = '4.7.2'
46+
47+
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
48+
# CLRVersion = ''
49+
50+
# Processor architecture (None, X86, Amd64) required by this module
51+
# ProcessorArchitecture = ''
52+
53+
# Modules that must be imported into the global environment prior to importing this module
54+
RequiredModules = @(@{ModuleName = 'PowerShellGet'; ModuleVersion = '2.1.3'; })
55+
56+
# Assemblies that must be loaded prior to importing this module
57+
RequiredAssemblies = @(
58+
'.\assembly\Microsoft.ApplicationInsights.2.12.0\Microsoft.ApplicationInsights.dll'
59+
)
60+
61+
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
62+
# ScriptsToProcess = @()
63+
64+
# Type files (.ps1xml) to be loaded when importing this module
65+
# TypesToProcess = @()
66+
67+
# Format files (.ps1xml) to be loaded when importing this module
68+
#FormatsToProcess = ''
69+
70+
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
71+
# NestedModules = @()
72+
73+
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
74+
FunctionsToExport = '*'
75+
76+
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
77+
CmdletsToExport = @('Install-AzModule', 'Uninstall-AzModule', 'Update-AzModule')
78+
79+
# Variables to export from this module
80+
# VariablesToExport = @()
81+
82+
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
83+
AliasesToExport = '*'
84+
85+
# DSC resources to export from this module
86+
# DscResourcesToExport = @()
87+
88+
# List of all modules packaged with this module
89+
# ModuleList = @()
90+
91+
# List of all files packaged with this module
92+
# FileList = @()
93+
94+
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
95+
PrivateData = @{
96+
97+
PSData = @{
98+
99+
# Tags applied to this module. These help with module discovery in online galleries.
100+
#Tags = ''
101+
102+
# A URL to the license for this module.
103+
LicenseUri = 'https://aka.ms/azps-license'
104+
105+
# A URL to the main website for this project.
106+
ProjectUri = 'https://github.com/Azure/azure-powershell'
107+
108+
# A URL to an icon representing this module.
109+
# IconUri = ''
110+
111+
# ReleaseNotes of this module
112+
ReleaseNotes = '* the first preview release'
113+
114+
# Prerelease string of this module
115+
# Prerelease = ''
116+
117+
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
118+
# RequireLicenseAcceptance = $false
119+
120+
# External dependent modules of this module
121+
ExternalModuleDependencies = @('PowerShellGet')
122+
123+
} # End of PSData hashtable
124+
125+
} # End of PrivateData hashtable
126+
127+
# HelpInfo URI of this module
128+
# HelpInfoURI = ''
129+
130+
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
131+
# DefaultCommandPrefix = ''
132+
133+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# ----------------------------------------------------------------------------------
2+
#
3+
# Copyright Microsoft Corporation
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.internal
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# ----------------------------------------------------------------------------------
14+
15+
$getModule = Get-Module -Name "PowerShellGet"
16+
if ($null -ne $getModule -and $getModule.Version -lt [System.Version]"2.1.3") {
17+
Write-Error "This module requires PowerShellGet version 2.1.3. An earlier version of PowerShellGet is imported in the current PowerShell session. Please open a new session before importing this module." -ErrorAction Stop
18+
}
19+
elseif ($null -eq $module) {
20+
Import-Module PowerShellGet -MinimumVersion 2.1.3 -Scope Global
21+
}
22+
23+
$exportedFunctions = @( Get-ChildItem -Path $PSScriptRoot/exports/*.ps1 -Recurse -ErrorAction SilentlyContinue )
24+
$internalFunctions = @( Get-ChildItem -Path $PSScriptRoot/internal/*.ps1 -ErrorAction SilentlyContinue )
25+
26+
$allFunctions = $exportedFunctions + $internalFunctions
27+
foreach($function in $allFunctions) {
28+
try {
29+
. $function.Fullname
30+
}
31+
catch {
32+
Write-Error -Message "Failed to import function $($function.fullname): $_"
33+
}
34+
}
35+
Export-ModuleMember -Function $exportedFunctions.Basename
36+
37+
$commandsWithRepositoryParameter = @(
38+
"Install-AzModule",
39+
"Uninstall-AzModule"
40+
)
41+
42+
Add-RepositoryArgumentCompleter -Cmdlets $commandsWithRepositoryParameter -ParameterName "Repository"

tools/Az.Tools.Installer/build.proj

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0"
3+
xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Target="Build">
4+
5+
<Import Project="$(MSBuildThisFileDirectory)..\..\Repo.props" />
6+
7+
<PropertyGroup>
8+
<PowerShellCoreCommandPrefix>pwsh -NonInteractive -NoLogo -NoProfile -Command</PowerShellCoreCommandPrefix>
9+
<ModuleName>Az.Tools.Installer</ModuleName>
10+
<ArtifactFolder>$(RepoArtifacts)Tools\</ArtifactFolder>
11+
</PropertyGroup>
12+
13+
<Target Name="Clean">
14+
<Message Text="Clean artifacts folder" />
15+
<RemoveDir Directories="$(ArtifactFolder)" />
16+
</Target>
17+
18+
<Target Name="Build">
19+
<Message Text="Build $(ModuleName)" />
20+
<ItemGroup>
21+
<PublishFiles Include="**" Exclude="*.proj"/>
22+
</ItemGroup>
23+
<Copy SourceFiles="@(PublishFiles)" DestinationFolder="$(ArtifactFolder)$(ModuleName)\%(RecursiveDir)" />
24+
</Target>
25+
26+
<Target Name="Test" DependsOnTargets="Build">
27+
28+
</Target>
29+
30+
<Target Name="Package">
31+
<Message Text="Package $(ModuleName)" />
32+
<Exec Command="$(PowerShellCoreCommandPrefix) &quot;$(RepoTools)\PublishToolsModule.ps1 -RepositoryLocation $(ArtifactFolder) -ModuleName $(ModuleName)&quot;" />
33+
</Target>
34+
</Project>

0 commit comments

Comments
 (0)