Skip to content

Commit 4efc983

Browse files
authored
Merge pull request #197 from microsoftgraph/po/PS51HardDependencyFix
PowerShell 5.1 hard dependency fix
2 parents ce3a1b1 + a592abd commit 4efc983

11 files changed

+33
-30
lines changed

.azure-pipelines/generate-beta-modules.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ jobs:
3636
displayName: 'Install AutoRest'
3737
inputs:
3838
command: 'custom'
39-
customCommand: 'install -g @autorest/autorest@3.0.6114'
39+
customCommand: 'install -g @autorest/autorest'
4040

4141
- task: PowerShell@2
4242
displayName: 'Build Auth Modules'
4343
inputs:
44-
filePath: '$(System.DefaultWorkingDirectory)/tools/BuildModule.ps1'
45-
arguments: '-Module "Authentication" -ModulePrefix $(MODULE_PREFIX) -ModuleVersion $(Module_Version) -EnableSigning -ReleaseNotes $(Release_Notes)'
44+
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1'
45+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory) -Build -EnableSigning'
4646
pwsh: true
4747

4848
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
@@ -122,7 +122,7 @@ jobs:
122122
displayName: 'Generate and Build Graph Resource Modules'
123123
inputs:
124124
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1'
125-
arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build -EnableSigning'
125+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build -EnableSigning'
126126
pwsh: true
127127

128128
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1

.azure-pipelines/generate-beta-rollup-module.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
displayName: 'Generate and Build Roll-Up Module'
3030
inputs:
3131
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1'
32-
arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)/$(GRAPH_VERSION)/ -BetaGraphVersion'
32+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)/$(GRAPH_VERSION)/ -BetaGraphVersion'
3333
pwsh: true
3434

3535
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1

.azure-pipelines/generate-v1.0-modules.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ jobs:
3737
displayName: 'Install AutoRest'
3838
inputs:
3939
command: 'custom'
40-
customCommand: 'install -g @autorest/autorest@3.0.6114'
40+
customCommand: 'install -g @autorest/autorest'
4141

4242
- task: PowerShell@2
4343
displayName: 'Build Auth Modules'
4444
inputs:
45-
filePath: '$(System.DefaultWorkingDirectory)/tools/BuildModule.ps1'
46-
arguments: '-Module "Authentication" -ModulePrefix $(MODULE_PREFIX) -ModuleVersion $(Module_Version) -EnableSigning'
45+
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1'
46+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory) -Build -EnableSigning'
4747
pwsh: true
4848

4949
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
@@ -123,7 +123,7 @@ jobs:
123123
displayName: 'Generate and Build Graph Resource Modules'
124124
inputs:
125125
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1'
126-
arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build -EnableSigning'
126+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build -EnableSigning'
127127
pwsh: true
128128

129129
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1

.azure-pipelines/generate-v1.0-rollup-module.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
displayName: 'Generate and Build Roll-Up Module'
3030
inputs:
3131
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1'
32-
arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\'
32+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\'
3333
pwsh: true
3434

3535
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1

.azure-pipelines/validate-pr-beta-modules.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ jobs:
3535
displayName: 'Install AutoRest'
3636
inputs:
3737
command: 'custom'
38-
customCommand: 'install -g @autorest/autorest@3.0.6114'
38+
customCommand: 'install -g @autorest/autorest'
3939

4040
- task: PowerShell@2
4141
displayName: 'Generate and Build Graph Resource Modules'
4242
inputs:
4343
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1'
44-
arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build'
44+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build'
4545
pwsh: true
4646

4747
- task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0

.azure-pipelines/validate-pr-v1.0-modules.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ jobs:
3535
displayName: 'Install AutoRest'
3636
inputs:
3737
command: 'custom'
38-
customCommand: 'install -g @autorest/autorest@3.0.6114'
38+
customCommand: 'install -g @autorest/autorest'
3939

4040
- task: PowerShell@2
4141
displayName: 'Generate and Build Graph Resource Modules'
4242
inputs:
4343
filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1'
44-
arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build'
44+
arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build'
4545
pwsh: true
4646

4747
- task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0

src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ DotNetFrameworkVersion = '4.7.2'
6363
# TypesToProcess = @()
6464

6565
# Format files (.ps1xml) to be loaded when importing this module
66-
FormatsToProcess = './Microsoft.Graph.Authentication.Format.ps1xml'
66+
FormatsToProcess = './Microsoft.Graph.Authentication.format.ps1xml'
6767

6868
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
6969
# NestedModules = @()

tools/BuildModule.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Param(
77
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ModuleVersion,
88
[Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string[]] $ReleaseNotes,
99
[int] $ModulePreviewNumber = -1,
10-
[string[]] $RequiredModules,
10+
[hashtable[]] $RequiredModules,
1111
[switch] $EnableSigning
1212
)
1313
$ErrorActionPreference = "Stop"

tools/GenerateModules.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ if ($BetaGraphVersion) {
3333
}
3434
$ModulePrefix = "Microsoft.Graph"
3535
$ModulesOutputDir = Join-Path $PSScriptRoot "..\src\$GraphVersion\"
36-
$AuthenticationModule = "Microsoft.Graph.Authentication"
3736
$OpenApiDocOutput = Join-Path $OpenApiDocOutput $GraphVersion
3837
$ArtifactsLocation = Join-Path $PSScriptRoot "..\artifacts\$GraphVersion"
39-
38+
$RequiredGraphModules = @()
4039
# PS Scripts
4140
$DownloadOpenApiDocPS1 = Join-Path $PSScriptRoot ".\DownloadOpenApiDoc.ps1" -Resolve
4241
$ManageGeneratedModulePS1 = Join-Path $PSScriptRoot ".\ManageGeneratedModule.ps1" -Resolve
@@ -53,10 +52,11 @@ if (-not (Test-Path $ArtifactsLocation)) {
5352
if (-not (Test-Path $ModuleMappingConfigPath)) {
5453
Write-Error "Module mapping file not be found: $ModuleMappingConfigPath."
5554
}
56-
5755
# Install module locally in order to specify it as a dependency for other modules down the generation pipeline.
5856
# https://stackoverflow.com/questions/46216038/how-do-i-define-requiredmodules-in-a-powershell-module-manifest-psd1.
59-
Install-Module $AuthenticationModule -Repository $RepositoryName -AllowPrerelease -Force
57+
$ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication"
58+
Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -AllowPrerelease -Force
59+
$RequiredGraphModules += @{ ModuleName = $ExistingAuthModule.Name ; RequiredVersion = $ExistingAuthModule.Version }
6060
if ($UpdateAutoRest) {
6161
# Update AutoRest.
6262
& AutoRest-beta --reset
@@ -123,10 +123,10 @@ $ModuleMapping.Keys | ForEach-Object {
123123
# Build generated module.
124124
if ($EnableSigning) {
125125
# Sign generated module.
126-
& $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $AuthenticationModule -ReleaseNotes $ModuleReleaseNotes -EnableSigning
126+
& $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $RequiredGraphModules -ReleaseNotes $ModuleReleaseNotes -EnableSigning
127127
}
128128
else {
129-
& $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $AuthenticationModule -ReleaseNotes $ModuleReleaseNotes
129+
& $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $RequiredGraphModules -ReleaseNotes $ModuleReleaseNotes
130130
}
131131

132132
if ($LASTEXITCODE) {

tools/GenerateRollUpModule.ps1

+7-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ $ModuleMetadataJson = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -R
3838
$ArtifactsLocation = Join-Path $PSScriptRoot "..\artifacts\$GraphVersion\"
3939
$GraphModuleLocation = Join-Path $PSScriptRoot "..\src\$GraphVersion\Graph\Graph"
4040
$RollUpModuleNuspec = Join-Path $GraphModuleLocation ".\$ModulePrefix"
41-
$RequiredGraphModules = New-Object collections.generic.list[string]
41+
$RequiredGraphModules = @()
4242
[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable
4343
[HashTable] $NuspecMetadata = Get-Content $ModuleMetadataJson | ConvertFrom-Json -AsHashTable
4444
$NuspecMetadata.Remove("assemblyOriginatorKeyFile")
@@ -76,14 +76,16 @@ elseif ($VersionState.Equals([VersionState]::Valid) -or $VersionState.Equals([Ve
7676
}
7777

7878
# Add auth module as a dependency.
79-
Install-Module "Microsoft.Graph.Authentication" -Repository $RepositoryName -AllowPrerelease -Force
80-
$RequiredGraphModules.Add("Microsoft.Graph.Authentication")
79+
$ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication"
80+
Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -AllowPrerelease -Force
81+
$RequiredGraphModules += @{ ModuleName = $ExistingAuthModule.Name ; ModuleVersion = $ExistingAuthModule.Version }
8182

8283
foreach ($RequiredModule in $ModuleMapping.Keys) {
8384
# Install module locally in order to specify it as a dependency of the roll-up module down the generation pipeline.
8485
# https://stackoverflow.com/questions/46216038/how-do-i-define-requiredmodules-in-a-powershell-module-manifest-psd1.
85-
Install-Module "$ModulePrefix.$RequiredModule" -Repository $RepositoryName -AllowPrerelease -Force
86-
$RequiredGraphModules.Add("$ModulePrefix.$RequiredModule")
86+
$ExistingWorkloadModule = Find-Module "$ModulePrefix.$RequiredModule"
87+
Install-Module $ExistingWorkloadModule.Name -Repository $RepositoryName -AllowPrerelease -Force
88+
$RequiredGraphModules += @{ ModuleName = $ExistingWorkloadModule.Name ; RequiredVersion = $ExistingWorkloadModule.Version }
8789
}
8890

8991
[HashTable]$ModuleManifestSettings = @{

tools/NuspecHelper.ps1

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ function Set-NuSpecValues(
44
[parameter(Position=1,Mandatory=$true)][ValidateScript({Test-Path $_ -PathType Leaf})][string] $NuSpecFilePath,
55
[parameter(Position=2,Mandatory=$true)][string] $VersionNumber,
66
[parameter(Position=3,Mandatory=$true)][string] $IconUrl,
7-
[parameter(Position=4)][string[]] $Dependencies,
7+
[parameter(Position=4)][hashtable[]] $Dependencies,
88
[parameter(Position=5)][string[]] $ReleaseNotes) {
99
$XmlDocument = New-Object System.Xml.XmlDocument
1010
$XmlDocument.Load($NuSpecFilePath)
@@ -69,7 +69,7 @@ function Set-ElementValue(
6969
function Set-Dependencies(
7070
[System.Xml.XmlDocument] $XmlDocument,
7171
[System.Xml.XmlElement] $MetadataElement,
72-
[string[]] $Dependencies) {
72+
[hashtable[]] $Dependencies) {
7373
if(-not $MetadataElement["dependencies"]){
7474
$NewDependenciesElement = $XmlDocument.CreateElement("dependencies", $XmlDocument.DocumentElement.NamespaceURI)
7575
$MetadataElement.AppendChild($NewDependenciesElement)
@@ -79,7 +79,8 @@ function Set-Dependencies(
7979

8080
foreach($Dependency in $Dependencies){
8181
$NewDependencyElement = $XmlDocument.CreateElement("dependency", $XmlDocument.DocumentElement.NamespaceURI)
82-
$NewDependencyElement.SetAttribute("id", $Dependency)
82+
$NewDependencyElement.SetAttribute("id", $Dependency.ModuleName)
83+
$NewDependencyElement.SetAttribute("version", $Dependency.ModuleVersion ?? $Dependency.RequiredVersion)
8384

8485
$MetadataElement["dependencies"].AppendChild($NewDependencyElement)
8586
}

0 commit comments

Comments
 (0)