diff --git a/.azure-pipelines/generate-beta-modules.yml b/.azure-pipelines/generate-beta-modules.yml index 5dc1f787889..5004038375f 100644 --- a/.azure-pipelines/generate-beta-modules.yml +++ b/.azure-pipelines/generate-beta-modules.yml @@ -36,13 +36,13 @@ jobs: displayName: 'Install AutoRest' inputs: command: 'custom' - customCommand: 'install -g @autorest/autorest@3.0.6114' + customCommand: 'install -g @autorest/autorest' - task: PowerShell@2 displayName: 'Build Auth Modules' inputs: - filePath: '$(System.DefaultWorkingDirectory)/tools/BuildModule.ps1' - arguments: '-Module "Authentication" -ModulePrefix $(MODULE_PREFIX) -ModuleVersion $(Module_Version) -EnableSigning -ReleaseNotes $(Release_Notes)' + filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory) -Build -EnableSigning' pwsh: true - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 @@ -122,7 +122,7 @@ jobs: displayName: 'Generate and Build Graph Resource Modules' inputs: filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1' - arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build -EnableSigning' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build -EnableSigning' pwsh: true - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 diff --git a/.azure-pipelines/generate-beta-rollup-module.yml b/.azure-pipelines/generate-beta-rollup-module.yml index 5a8347a077d..f6545db63dc 100644 --- a/.azure-pipelines/generate-beta-rollup-module.yml +++ b/.azure-pipelines/generate-beta-rollup-module.yml @@ -29,7 +29,7 @@ jobs: displayName: 'Generate and Build Roll-Up Module' inputs: filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1' - arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)/$(GRAPH_VERSION)/ -BetaGraphVersion' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)/$(GRAPH_VERSION)/ -BetaGraphVersion' pwsh: true - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 diff --git a/.azure-pipelines/generate-v1.0-modules.yml b/.azure-pipelines/generate-v1.0-modules.yml index 510f2a0618d..725223c60fb 100644 --- a/.azure-pipelines/generate-v1.0-modules.yml +++ b/.azure-pipelines/generate-v1.0-modules.yml @@ -37,13 +37,13 @@ jobs: displayName: 'Install AutoRest' inputs: command: 'custom' - customCommand: 'install -g @autorest/autorest@3.0.6114' + customCommand: 'install -g @autorest/autorest' - task: PowerShell@2 displayName: 'Build Auth Modules' inputs: - filePath: '$(System.DefaultWorkingDirectory)/tools/BuildModule.ps1' - arguments: '-Module "Authentication" -ModulePrefix $(MODULE_PREFIX) -ModuleVersion $(Module_Version) -EnableSigning' + filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory) -Build -EnableSigning' pwsh: true - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 @@ -123,7 +123,7 @@ jobs: displayName: 'Generate and Build Graph Resource Modules' inputs: filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1' - arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build -EnableSigning' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build -EnableSigning' pwsh: true - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 diff --git a/.azure-pipelines/generate-v1.0-rollup-module.yml b/.azure-pipelines/generate-v1.0-rollup-module.yml index 565f433e7c9..7815b1c5a58 100644 --- a/.azure-pipelines/generate-v1.0-rollup-module.yml +++ b/.azure-pipelines/generate-v1.0-rollup-module.yml @@ -29,7 +29,7 @@ jobs: displayName: 'Generate and Build Roll-Up Module' inputs: filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1' - arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\' pwsh: true - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 diff --git a/.azure-pipelines/validate-pr-beta-modules.yml b/.azure-pipelines/validate-pr-beta-modules.yml index 414c122c131..ce266de6826 100644 --- a/.azure-pipelines/validate-pr-beta-modules.yml +++ b/.azure-pipelines/validate-pr-beta-modules.yml @@ -35,13 +35,13 @@ jobs: displayName: 'Install AutoRest' inputs: command: 'custom' - customCommand: 'install -g @autorest/autorest@3.0.6114' + customCommand: 'install -g @autorest/autorest' - task: PowerShell@2 displayName: 'Generate and Build Graph Resource Modules' inputs: filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1' - arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -BetaGraphVersion -Build' pwsh: true - task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0 diff --git a/.azure-pipelines/validate-pr-v1.0-modules.yml b/.azure-pipelines/validate-pr-v1.0-modules.yml index 5353e9e3d6e..69db1a749e8 100644 --- a/.azure-pipelines/validate-pr-v1.0-modules.yml +++ b/.azure-pipelines/validate-pr-v1.0-modules.yml @@ -35,13 +35,13 @@ jobs: displayName: 'Install AutoRest' inputs: command: 'custom' - customCommand: 'install -g @autorest/autorest@3.0.6114' + customCommand: 'install -g @autorest/autorest' - task: PowerShell@2 displayName: 'Generate and Build Graph Resource Modules' inputs: filePath: '$(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1' - arguments: '-RepositoryName $(Repository_Name) -RepositoryApiKey $(Api_Key) -ModuleVersion $(Module_Version) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build' + arguments: '-RepositoryApiKey $(Api_Key) -ArtifactsLocation $(Build.ArtifactStagingDirectory)\$(GRAPH_VERSION)\ -UseLocalDoc -Build' pwsh: true - task: YodLabs.O365PostMessage.O365PostMessageBuild.O365PostMessageBuild@0 diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 index 6f47735e15f..fd9fbf03c7b 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 @@ -63,7 +63,7 @@ DotNetFrameworkVersion = '4.7.2' # TypesToProcess = @() # Format files (.ps1xml) to be loaded when importing this module -FormatsToProcess = './Microsoft.Graph.Authentication.Format.ps1xml' +FormatsToProcess = './Microsoft.Graph.Authentication.format.ps1xml' # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess # NestedModules = @() diff --git a/tools/BuildModule.ps1 b/tools/BuildModule.ps1 index e9fed49cbe1..122099a64c2 100644 --- a/tools/BuildModule.ps1 +++ b/tools/BuildModule.ps1 @@ -7,7 +7,7 @@ Param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ModuleVersion, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string[]] $ReleaseNotes, [int] $ModulePreviewNumber = -1, - [string[]] $RequiredModules, + [hashtable[]] $RequiredModules, [switch] $EnableSigning ) $ErrorActionPreference = "Stop" diff --git a/tools/GenerateModules.ps1 b/tools/GenerateModules.ps1 index cc332d1f50f..24085ad851a 100644 --- a/tools/GenerateModules.ps1 +++ b/tools/GenerateModules.ps1 @@ -33,10 +33,9 @@ if ($BetaGraphVersion) { } $ModulePrefix = "Microsoft.Graph" $ModulesOutputDir = Join-Path $PSScriptRoot "..\src\$GraphVersion\" -$AuthenticationModule = "Microsoft.Graph.Authentication" $OpenApiDocOutput = Join-Path $OpenApiDocOutput $GraphVersion $ArtifactsLocation = Join-Path $PSScriptRoot "..\artifacts\$GraphVersion" - +$RequiredGraphModules = @() # PS Scripts $DownloadOpenApiDocPS1 = Join-Path $PSScriptRoot ".\DownloadOpenApiDoc.ps1" -Resolve $ManageGeneratedModulePS1 = Join-Path $PSScriptRoot ".\ManageGeneratedModule.ps1" -Resolve @@ -53,10 +52,11 @@ if (-not (Test-Path $ArtifactsLocation)) { if (-not (Test-Path $ModuleMappingConfigPath)) { Write-Error "Module mapping file not be found: $ModuleMappingConfigPath." } - # Install module locally in order to specify it as a dependency for other modules down the generation pipeline. # https://stackoverflow.com/questions/46216038/how-do-i-define-requiredmodules-in-a-powershell-module-manifest-psd1. -Install-Module $AuthenticationModule -Repository $RepositoryName -AllowPrerelease -Force +$ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication" +Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -AllowPrerelease -Force +$RequiredGraphModules += @{ ModuleName = $ExistingAuthModule.Name ; RequiredVersion = $ExistingAuthModule.Version } if ($UpdateAutoRest) { # Update AutoRest. & AutoRest-beta --reset @@ -123,10 +123,10 @@ $ModuleMapping.Keys | ForEach-Object { # Build generated module. if ($EnableSigning) { # Sign generated module. - & $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $AuthenticationModule -ReleaseNotes $ModuleReleaseNotes -EnableSigning + & $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $RequiredGraphModules -ReleaseNotes $ModuleReleaseNotes -EnableSigning } else { - & $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $AuthenticationModule -ReleaseNotes $ModuleReleaseNotes + & $BuildModulePS1 -Module $ModuleName -ModulePrefix $ModulePrefix -GraphVersion $GraphVersion -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $RequiredGraphModules -ReleaseNotes $ModuleReleaseNotes } if ($LASTEXITCODE) { diff --git a/tools/GenerateRollUpModule.ps1 b/tools/GenerateRollUpModule.ps1 index 2706ea0b608..a529dfb0f1f 100644 --- a/tools/GenerateRollUpModule.ps1 +++ b/tools/GenerateRollUpModule.ps1 @@ -38,7 +38,7 @@ $ModuleMetadataJson = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -R $ArtifactsLocation = Join-Path $PSScriptRoot "..\artifacts\$GraphVersion\" $GraphModuleLocation = Join-Path $PSScriptRoot "..\src\$GraphVersion\Graph\Graph" $RollUpModuleNuspec = Join-Path $GraphModuleLocation ".\$ModulePrefix" -$RequiredGraphModules = New-Object collections.generic.list[string] +$RequiredGraphModules = @() [HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable [HashTable] $NuspecMetadata = Get-Content $ModuleMetadataJson | ConvertFrom-Json -AsHashTable $NuspecMetadata.Remove("assemblyOriginatorKeyFile") @@ -76,14 +76,16 @@ elseif ($VersionState.Equals([VersionState]::Valid) -or $VersionState.Equals([Ve } # Add auth module as a dependency. - Install-Module "Microsoft.Graph.Authentication" -Repository $RepositoryName -AllowPrerelease -Force - $RequiredGraphModules.Add("Microsoft.Graph.Authentication") + $ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication" + Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -AllowPrerelease -Force + $RequiredGraphModules += @{ ModuleName = $ExistingAuthModule.Name ; ModuleVersion = $ExistingAuthModule.Version } foreach ($RequiredModule in $ModuleMapping.Keys) { # Install module locally in order to specify it as a dependency of the roll-up module down the generation pipeline. # https://stackoverflow.com/questions/46216038/how-do-i-define-requiredmodules-in-a-powershell-module-manifest-psd1. - Install-Module "$ModulePrefix.$RequiredModule" -Repository $RepositoryName -AllowPrerelease -Force - $RequiredGraphModules.Add("$ModulePrefix.$RequiredModule") + $ExistingWorkloadModule = Find-Module "$ModulePrefix.$RequiredModule" + Install-Module $ExistingWorkloadModule.Name -Repository $RepositoryName -AllowPrerelease -Force + $RequiredGraphModules += @{ ModuleName = $ExistingWorkloadModule.Name ; RequiredVersion = $ExistingWorkloadModule.Version } } [HashTable]$ModuleManifestSettings = @{ diff --git a/tools/NuspecHelper.ps1 b/tools/NuspecHelper.ps1 index 2d27bcba532..33cfeb8400a 100644 --- a/tools/NuspecHelper.ps1 +++ b/tools/NuspecHelper.ps1 @@ -4,7 +4,7 @@ function Set-NuSpecValues( [parameter(Position=1,Mandatory=$true)][ValidateScript({Test-Path $_ -PathType Leaf})][string] $NuSpecFilePath, [parameter(Position=2,Mandatory=$true)][string] $VersionNumber, [parameter(Position=3,Mandatory=$true)][string] $IconUrl, - [parameter(Position=4)][string[]] $Dependencies, + [parameter(Position=4)][hashtable[]] $Dependencies, [parameter(Position=5)][string[]] $ReleaseNotes) { $XmlDocument = New-Object System.Xml.XmlDocument $XmlDocument.Load($NuSpecFilePath) @@ -69,7 +69,7 @@ function Set-ElementValue( function Set-Dependencies( [System.Xml.XmlDocument] $XmlDocument, [System.Xml.XmlElement] $MetadataElement, - [string[]] $Dependencies) { + [hashtable[]] $Dependencies) { if(-not $MetadataElement["dependencies"]){ $NewDependenciesElement = $XmlDocument.CreateElement("dependencies", $XmlDocument.DocumentElement.NamespaceURI) $MetadataElement.AppendChild($NewDependenciesElement) @@ -79,7 +79,8 @@ function Set-Dependencies( foreach($Dependency in $Dependencies){ $NewDependencyElement = $XmlDocument.CreateElement("dependency", $XmlDocument.DocumentElement.NamespaceURI) - $NewDependencyElement.SetAttribute("id", $Dependency) + $NewDependencyElement.SetAttribute("id", $Dependency.ModuleName) + $NewDependencyElement.SetAttribute("version", $Dependency.ModuleVersion ?? $Dependency.RequiredVersion) $MetadataElement["dependencies"].AppendChild($NewDependencyElement) }