From cfa46f8468262a4a2295f23867153f739eea0b01 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Mon, 18 Jul 2022 10:44:55 -0700 Subject: [PATCH 01/30] Add ci-build --- .azure-pipelines/ci-build.yml | 66 +++++++++++++++++++++++++++++++++++ config/ModulesMapping.jsonc | 14 ++++---- 2 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 .azure-pipelines/ci-build.yml diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml new file mode 100644 index 00000000000..31e882d4501 --- /dev/null +++ b/.azure-pipelines/ci-build.yml @@ -0,0 +1,66 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) +parameters: + - name: BuildAgent + default: 1es-windows-ps-compute + displayName: Build Agent + +variables: + BuildAgent: ${{ parameters.BuildAgent }} + GitUserEmail: 'GraphTooling@service.microsoft.com' + GitUserName: 'Microsoft Graph DevX Tooling' + +pool: $(BuildAgent) + +trigger: + branches: + include: + - main + - features/2.0 +pr: none + +steps: + - template: ../common-templates/install-tools-template.yml + - template: ../common-templates/security-prechecks-template.yml +# TODO: Load from templates. +# Authentication module. + - task: PowerShell@2 + displayName: Generate Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build -Test + + - task: PowerShell@2 + displayName: Test Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test +# Workload modules. + - task: PowerShell@2 + displayName: Generate Workload Modules + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -UpdateAutoRest -ExcludeExampleTemplates -ExcludeNotesSection + + - task: PowerShell@2 + displayName: Test Workload Modules + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Test +# Meta-Module module. + - task: PowerShell@2 + displayName: 'Generate Meta-Module' + inputs: + targetType: inline + pwsh: true + script: | + $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 7c691c341ea..1a15d71aa43 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -6,18 +6,18 @@ "CloudCommunications": "^users.onlineMeeting$|^users.presence$|^communications\\.", "Compliance": "^compliance\\.", "CrossDeviceExperiences": "^users.userActivity$|^users.device$", - "Devices.CloudPrint": "^print\\.", - "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", - "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", + // "Devices.CloudPrint": "^print\\.", + // "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", + // "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", "DeviceManagement.Actions": "^deviceManagement.Actions$", "DeviceManagement.Functions": "^deviceManagement.Functions$", "DirectoryObjects": "^directoryObjects\\.", - "Education": "^education\\.", - "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", - "Financials": "^financials\\.", + // "Education": "^education\\.", + // "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", + // "Financials": "^financials\\.", "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", @@ -31,7 +31,7 @@ "SchemaExtensions": "^schemaExtensions\\.", "Search": "^search\\.|^external\\.", "Security": "^security\\.", - "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", + // "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", "Users.Actions": "^users.Actions$", From 04f80ccc813e46f8af4768831dbcfc8020d094ec Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Mon, 18 Jul 2022 10:47:02 -0700 Subject: [PATCH 02/30] Set up CI with Azure Pipelines [skip ci] --- .azure-pipelines/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 31e882d4501..cd25471d5a7 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -1,4 +1,4 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r) parameters: From 7a1960684e8e8d123ea802118dac44e436a87d80 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Mon, 18 Jul 2022 13:35:34 -0700 Subject: [PATCH 03/30] Install required tools. --- .azure-pipelines/ci-build.yml | 11 +++-- .../install-tools-template.yml | 48 +++++-------------- config/ModulesMapping.jsonc | 6 +-- 3 files changed, 21 insertions(+), 44 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index cd25471d5a7..062b0912981 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -21,8 +21,8 @@ trigger: pr: none steps: - - template: ../common-templates/install-tools-template.yml - - template: ../common-templates/security-prechecks-template.yml + - template: ./common-templates/install-tools-template.yml + - template: ./common-templates/security-prechecks-template.yml # TODO: Load from templates. # Authentication module. - task: PowerShell@2 @@ -31,7 +31,7 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build -Test + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build - task: PowerShell@2 displayName: Test Authentication Module @@ -47,7 +47,7 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -UpdateAutoRest -ExcludeExampleTemplates -ExcludeNotesSection + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -ExcludeExampleTemplates -ExcludeNotesSection - task: PowerShell@2 displayName: Test Workload Modules @@ -55,10 +55,11 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Test + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test # Meta-Module module. - task: PowerShell@2 displayName: 'Generate Meta-Module' + enabled: false inputs: targetType: inline pwsh: true diff --git a/.azure-pipelines/common-templates/install-tools-template.yml b/.azure-pipelines/common-templates/install-tools-template.yml index caf2e00aa71..3e5b1914335 100644 --- a/.azure-pipelines/common-templates/install-tools-template.yml +++ b/.azure-pipelines/common-templates/install-tools-template.yml @@ -3,66 +3,42 @@ steps: - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 2 LTS' - inputs: - debugMode: false - version: 2.x - - - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 3 LTS' - inputs: - debugMode: false - version: 3.x - - - task: UseDotNet@2 - displayName: 'Use .NET Core SDK 6 Current' + displayName: Use .NET SDK inputs: debugMode: false version: 6.x - task: NuGetToolInstaller@1 - displayName: 'Install Nuget 5.7' - inputs: - versionSpec: 5.7.0 - checkLatest: false # Optional + displayName: Install Nuget - task: NuGetAuthenticate@0 - - task: PowerShell@2 - displayName: 'Version Check' + displayName: Version Check inputs: targetType: inline pwsh: true script: | - Write-Host $PSVersionTable.PSVersion - Write-Host $host.Version - Write-Host (Get-Host).Version + Write-Output $PSVersionTable - task: NodeTool@0 - displayName: 'Install NodeJs' - inputs: - versionSpec: '14.18.2' - checkLatest: true # Optional - - - task: Npm@1 - displayName: 'Install AutoRest' + displayName: Install NodeJs inputs: - command: 'custom' - customCommand: 'install -g autorest@latest' + versionSpec: 16.x - task: Npm@1 - displayName: 'Install Rush' + displayName: Install AutoRest inputs: - command: 'custom' - customCommand: 'install -g @microsoft/rush' + command: custom + customCommand: install -g autorest@latest - task: PowerShell@2 - displayName: 'Register PS Repository' + displayName: Register PS Repository + enabled: false inputs: targetType: inline pwsh: true - errorActionPreference: 'continue' + errorActionPreference: continue script: | $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue Get-PSRepository diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 1a15d71aa43..a5bd8c60387 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -9,7 +9,7 @@ // "Devices.CloudPrint": "^print\\.", // "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", // "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", - "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", + // "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", "DeviceManagement.Actions": "^deviceManagement.Actions$", @@ -18,9 +18,9 @@ // "Education": "^education\\.", // "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", // "Financials": "^financials\\.", - "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", + // "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", - "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", + // "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", "Identity.SignIns": "^organization.certificateBasedAuthConfiguration$|^invitations\\.|^identityProviders\\.|^oauth2PermissionGrants\\.|^identityProtection\\.|^dataPolicyOperations\\.|^identity.identityUserFlow$|^trustFramework\\.|^informationProtection\\.|^policies\\.|^users.authentication$|^users.informationProtection$|^identity.conditionalAccessRoot$", "Mail": "^users.inferenceClassification$|^users.mailFolder$|^users.message$", "Notes": "^users.onenote$|^groups.onenote$|^sites.onenote$", From 5adcc9e6a582a3b6ba44a02c371c97bc5a4d6248 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Mon, 18 Jul 2022 14:33:13 -0700 Subject: [PATCH 04/30] Temorarily skip tests. --- .azure-pipelines/ci-build.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 062b0912981..247e416ddd9 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -35,6 +35,7 @@ steps: - task: PowerShell@2 displayName: Test Authentication Module + enabled: false inputs: targetType: inline pwsh: true @@ -51,6 +52,7 @@ steps: - task: PowerShell@2 displayName: Test Workload Modules + enabled: false inputs: targetType: inline pwsh: true From 31cd22ab11ff22940eed66396a33eaa8b992173d Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Mon, 18 Jul 2022 16:17:51 -0700 Subject: [PATCH 05/30] Remove broken API. --- config/ModulesMapping.jsonc | 2 +- src/Security/Security.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index a5bd8c60387..9c1d75e813c 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -17,7 +17,7 @@ "DirectoryObjects": "^directoryObjects\\.", // "Education": "^education\\.", // "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", - // "Financials": "^financials\\.", + "Financials": "^financials\\.", // "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", // "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", diff --git a/src/Security/Security.md b/src/Security/Security.md index 561497fc46f..745c205efba 100644 --- a/src/Security/Security.md +++ b/src/Security/Security.md @@ -18,7 +18,7 @@ require: ``` yaml directive: # Remove invalid paths. - - remove-path-by-operation: ^security_.*Alerts_v2$ + - remove-path-by-operation: ^security(_.*Alerts_v2|.cases.ediscoveryCases.noncustodialDataSources_.*DataSource)$ # Remove cmdlets - where: verb: Get|Update From f9fbcc67a2bb11fdfe767386fe01bbd0d98af6b1 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Mon, 18 Jul 2022 16:49:15 -0700 Subject: [PATCH 06/30] Enable all modules. --- config/ModulesMapping.jsonc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 9c1d75e813c..b90e094e3e3 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -6,21 +6,21 @@ "CloudCommunications": "^users.onlineMeeting$|^users.presence$|^communications\\.", "Compliance": "^compliance\\.", "CrossDeviceExperiences": "^users.userActivity$|^users.device$", - // "Devices.CloudPrint": "^print\\.", - // "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", - // "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", - // "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", + "Devices.CloudPrint": "^print\\.", + "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", + "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", + "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", - "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", + // // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", "DeviceManagement.Actions": "^deviceManagement.Actions$", "DeviceManagement.Functions": "^deviceManagement.Functions$", "DirectoryObjects": "^directoryObjects\\.", - // "Education": "^education\\.", - // "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", + "Education": "^education\\.", + "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", "Financials": "^financials\\.", - // "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", + "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", - // "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", + "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", "Identity.SignIns": "^organization.certificateBasedAuthConfiguration$|^invitations\\.|^identityProviders\\.|^oauth2PermissionGrants\\.|^identityProtection\\.|^dataPolicyOperations\\.|^identity.identityUserFlow$|^trustFramework\\.|^informationProtection\\.|^policies\\.|^users.authentication$|^users.informationProtection$|^identity.conditionalAccessRoot$", "Mail": "^users.inferenceClassification$|^users.mailFolder$|^users.message$", "Notes": "^users.onenote$|^groups.onenote$|^sites.onenote$", @@ -31,7 +31,7 @@ "SchemaExtensions": "^schemaExtensions\\.", "Search": "^search\\.|^external\\.", "Security": "^security\\.", - // "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", + "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", "Users.Actions": "^users.Actions$", From 6222b780f3d1c4cb4388018a4150a0c92978414a Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 19 Jul 2022 08:26:22 -0700 Subject: [PATCH 07/30] Increate timeout. --- .azure-pipelines/ci-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 247e416ddd9..c3fae95ff58 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -20,6 +20,7 @@ trigger: - features/2.0 pr: none +timeoutInMinutes: 840 steps: - template: ./common-templates/install-tools-template.yml - template: ./common-templates/security-prechecks-template.yml From 8d6fff46279e6e2915a972d01251cb89463e23f0 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 19 Jul 2022 08:28:41 -0700 Subject: [PATCH 08/30] Move CI build to a job. --- .azure-pipelines/ci-build.yml | 95 ++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index c3fae95ff58..9c9089fc32b 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -20,51 +20,54 @@ trigger: - features/2.0 pr: none -timeoutInMinutes: 840 -steps: - - template: ./common-templates/install-tools-template.yml - - template: ./common-templates/security-prechecks-template.yml -# TODO: Load from templates. -# Authentication module. - - task: PowerShell@2 - displayName: Generate Authentication Module - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build +jobs: +- job: MsGraphPsSdkCiBuild + displayName: Microsoft Graph PowerShell SDK CI Build + timeoutInMinutes: 840 + steps: + - template: ./common-templates/install-tools-template.yml + - template: ./common-templates/security-prechecks-template.yml + # TODO: Load from templates. + # Authentication module. + - task: PowerShell@2 + displayName: Generate Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build - - task: PowerShell@2 - displayName: Test Authentication Module - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test -# Workload modules. - - task: PowerShell@2 - displayName: Generate Workload Modules - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -ExcludeExampleTemplates -ExcludeNotesSection + - task: PowerShell@2 + displayName: Test Authentication Module + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test + # Workload modules. + - task: PowerShell@2 + displayName: Generate Workload Modules + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -ExcludeExampleTemplates -ExcludeNotesSection - - task: PowerShell@2 - displayName: Test Workload Modules - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test -# Meta-Module module. - - task: PowerShell@2 - displayName: 'Generate Meta-Module' - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 + - task: PowerShell@2 + displayName: Test Workload Modules + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test + # Meta-Module module. + - task: PowerShell@2 + displayName: 'Generate Meta-Module' + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 From 5e3299eb63a6725420df3ee6a7d1f050932e2b69 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 19 Jul 2022 09:39:07 -0700 Subject: [PATCH 09/30] Rename ReplyAll commands. --- src/Users.Actions/Users.Actions.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/Users.Actions/Users.Actions.md b/src/Users.Actions/Users.Actions.md index 45dcbdde715..2960410997c 100644 --- a/src/Users.Actions/Users.Actions.md +++ b/src/Users.Actions/Users.Actions.md @@ -49,16 +49,16 @@ directive: subject: $1Default$2 - where: verb: Invoke - subject: ^(Reply)(UserMessage|UserMailFolderMessage)$ + subject: ^(Reply)(UserMessage|UserMailFolderMessage|UserMailFolderChildFolderMessage)$ variant: ^Reply1$|^ReplyExpanded1$|^ReplyViaIdentity1$|^ReplyViaIdentityExpanded1$ set: subject: $1All$2 - where: verb: New - subject: ^(User)(MessageReply|MailFolderMessageReply)$ + subject: ^(User)(Message|MailFolderMessage|MailFolderChildFolderMessage)(Reply)$ variant: ^Create1$|^CreateExpanded1$|^CreateViaIdentity1$|^CreateViaIdentityExpanded1$ set: - subject: $1$2All + subject: $1$2$3All # https://docs.microsoft.com/en-us/graph/api/resources/intune-devices-devicelogcollectionresponse?view=graph-rest-beta - where: verb: New @@ -89,6 +89,16 @@ directive: set: subject: Reprovision$1CloudPc alias: Invoke-MgCloudUserManagedDevice + - where: + subject: ^(UserAuthenticationMethod)SmSign$ + set: + subject: $1SmsSignIn + alias: ${verb}-MgUserAuthenticationMethodSmSign + - where: + subject: ^(UserSign)$ + set: + subject: $1InSession + alias: ${verb}-MgUserSign ``` ### Versioning From a757024d17b9257ceac60a1b3cac9a98e6d08f6e Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 19 Jul 2022 11:00:10 -0700 Subject: [PATCH 10/30] Exclude modules with broken APIs. --- config/ModulesMapping.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index b90e094e3e3..5a4f99427e3 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -13,7 +13,7 @@ "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", // // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", "DeviceManagement.Actions": "^deviceManagement.Actions$", - "DeviceManagement.Functions": "^deviceManagement.Functions$", + // // "DeviceManagement.Functions": "^deviceManagement.Functions$", "DirectoryObjects": "^directoryObjects\\.", "Education": "^education\\.", "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", From 5ccd9ceb219395f64a556021554ca818b4ba1fc8 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 19 Jul 2022 13:36:38 -0700 Subject: [PATCH 11/30] Fix groups module. --- config/ModulesMapping.jsonc | 2 +- src/Groups/Groups.md | 2 +- .../Identity.Governance.md | 30 ++++++++----------- 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 5a4f99427e3..031351a5336 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -35,6 +35,6 @@ "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", "Users.Actions": "^users.Actions$", - "Users.Functions": "^users.Functions$", + // // "Users.Functions": "^users.Functions$", "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" } \ No newline at end of file diff --git a/src/Groups/Groups.md b/src/Groups/Groups.md index bf3437e710f..8ea32b7689e 100644 --- a/src/Groups/Groups.md +++ b/src/Groups/Groups.md @@ -17,7 +17,7 @@ require: ``` yaml directive: - - remove-path-by-operation: .*\.onenote\..*parent.*|.*\.calendarView.*|.*\.notebooks\.section.*|.*\.sectionGroups\.section.*|.*\.sections\.pages.*|.*\.calendar\.events\..*$|.*\.events\..*$ + - remove-path-by-operation: groups\.groupLifecyclePolicies_.*$|groups_(Get|Create|Update|Delete)GroupLifecyclePolicies$|groups\.team.*$|users\.joinedGroups.*$|groups\.sites\.onenote.*$|.*\.onenote\..*parent.*|.*\.calendarView.*|.*\.notebooks\.section.*|.*\.sectionGroups\.section.*|.*\.sections\.pages.*|.*\.calendar\.events\..*$|.*\.events\..*$ # Remove duplicates. - where: subject: ^(GroupLifecyclePolicy)(\1)+ diff --git a/src/Identity.Governance/Identity.Governance.md b/src/Identity.Governance/Identity.Governance.md index 9d8998c1c50..e3b3f92de5b 100644 --- a/src/Identity.Governance/Identity.Governance.md +++ b/src/Identity.Governance/Identity.Governance.md @@ -17,12 +17,8 @@ require: ``` yaml directive: - - remove-path-by-operation: ^identityGovernance_(Get|Create|Update|Set|Delete)EntitlementManagement$|^identityGovernance\.entitlementManagement(_.*AccessPackageResourceRoleScopes|\.accessPackageResourceRoleScopes.*|\.accessPackageAssignmentPolicies\..*|\.accessPackageAssignmentRequests\..*|\.accessPackageAssignmentResourceRoles\..*|\.accessPackageAssignments\..*|\.accessPackageCatalogs\..*|\.accessPackageResourceRequests\..*|\.accessPackageResources\..*|\.accessPackages\..*)|^identityGovernance\.accessReviews\.definitions\.instances\.decisions\.(instance_.*)|^identityGovernance\.accessReviews\.definitions\.instances\.stages\.decisions.*$ + - remove-path-by-operation: ^identityGovernance_(Get|Create|Update|Set|Delete)EntitlementManagement$|^identityGovernance\.entitlementManagement(_.*AccessPackageResourceRoleScopes|\.accessPackageResourceRoleScopes.*|\.accessPackageAssignmentPolicies\..*|\.accessPackageAssignmentRequests\..*|\.accessPackageAssignmentResourceRoles\..*|\.accessPackageAssignments\..*|\.accessPackageCatalogs\..*|\.accessPackageResourceRequests\..*|\.accessPackageResources\..*|\.accessPackages\..*)|^identityGovernance\.accessReviews\.definitions\.instances\.decisions\.instance(\.|_).*|^identityGovernance\.accessReviews\.definitions\.instances(\.stages\.decisions.*)$|^privilegedAccess.roleAssignmentRequests.(resource|roleDefinition).*$|^privilegedAccess.roleAssignments.(resource|roleDefinition).*$|^privilegedAccess.roleDefinitions.(resource|roleSetting).*$|^privilegedAccess.roleSettings.(resource|roleDefinition).*$|(^agreements.|^identityGovernance.termsGraphOPreUse.agreements.).*files.*$ # Remove cmdlets - - where: - subject: ^AgreementFile$ - variant: ^Get1$|^GetViaIdentity1$|^Update1$|^UpdateExpanded1$|^UpdateViaIdentity1$|^UpdateViaIdentityExpanded1$|^Delete1$|^DeleteViaIdentity1$ - remove: true - where: verb: Get|Remove|Set subject: (.*)(EntitlementManagement)AccessPackageRefAccessPackageCatalog$ @@ -41,7 +37,7 @@ directive: remove: true - where: verb: Get|Remove|Update - subject: (.*)(EntitlementManagement)AssignmentAccessPackage + subject: (.*)(EntitlementManagement)AssignmentAccessPackage$ remove: true - where: verb: Get|Remove|Update @@ -81,7 +77,7 @@ directive: remove: true - where: verb: Get - subject: (.*)(EntitlementManagement)AssignmentRequestAccessPackage + subject: (.*)(EntitlementManagement)AssignmentRequestAccessPackage$ remove: true - where: verb: Get|Remove|Update @@ -149,11 +145,11 @@ directive: remove: true - where: verb: Get|Remove|Set - subject: (.*)(EntitlementManagement)CatalogGraphRefAccessPackage + subject: (.*)(EntitlementManagement)CatalogGraphRefAccessPackage$ remove: true - where: verb: Get|New|Remove|Update|Set|Invoke - subject: (.*)(EntitlementManagement)CatalogAccessPackage + subject: (.*)(EntitlementManagement)CatalogAccessPackage$ remove: true - where: verb: Get @@ -244,6 +240,10 @@ directive: subject: (.*)(EntitlementManagement)AccessPackageAssignmentPolicy$ variant: ^(Get1|List1|GetViaIdentity1|Create1|CreateExpanded1|CreateViaIdentity|CreateViaIdentityExpanded|Update1|UpdateExpanded1|UpdateViaIdentity1|UpdateViaIdentityExpanded1|Delete1|DeleteViaIdentity1)$ remove: true + - where: + subject: (.*)Privileged(Access|AccessResource)RoleAssignmentRequest$ + variant: ^(Update1|UpdateExpanded1|UpdateViaIdentity1|UpdateViaIdentityExpanded1)$ + remove: true - where: verb: Remove subject: (.*)(EntitlementManagement)Setting$ @@ -257,16 +257,12 @@ directive: subject: (.*)(IdentityGovernance)AccessReview$ remove: true - where: - verb: New|Remove|Update|Get|Add|Invoke|Reset|Send|Set|Stop - subject: (.*)(IdentityGovernance)(AccessReviewDefinition|AccessReviewHistoryDefinition|AccessReviewPolicy)(.*)$ - remove: true - - where: - verb: New|Remove|Update|Get - subject: ^(.*)(IdentityGovernance)Term$ + verb: New|Remove|Update|Get|Invoke + subject: (.*)(IdentityGovernance)AppConsent$ remove: true - where: - verb: New|Remove|Update|Get|Invoke - subject: (.*)(IdentityGovernance)AppConsent + verb: New|Remove|Update + subject: ^(.*)EntitlementManagementConnectedOrganization(Internal|External)Sponsor$ remove: true # Rename cmdlets with duplicates in their name. - where: From 6adc20564432dc8a7ab2e7c93d59c3f63ab32847 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Tue, 19 Jul 2022 16:04:54 -0700 Subject: [PATCH 12/30] Remove Financials directive. --- config/ModulesMapping.jsonc | 10 +++++----- src/Financials/Financials.md | 16 +--------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 031351a5336..c5fafe6bcbe 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -11,9 +11,9 @@ "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", - // // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", - "DeviceManagement.Actions": "^deviceManagement.Actions$", - // // "DeviceManagement.Functions": "^deviceManagement.Functions$", + // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", + // "DeviceManagement.Actions": "^deviceManagement.Actions$", + // "DeviceManagement.Functions": "^deviceManagement.Functions$", "DirectoryObjects": "^directoryObjects\\.", "Education": "^education\\.", "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", @@ -32,9 +32,9 @@ "Search": "^search\\.|^external\\.", "Security": "^security\\.", "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", - "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", + // "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", "Users.Actions": "^users.Actions$", - // // "Users.Functions": "^users.Functions$", + // "Users.Functions": "^users.Functions$", "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" } \ No newline at end of file diff --git a/src/Financials/Financials.md b/src/Financials/Financials.md index 50300fbfccd..427b254eca7 100644 --- a/src/Financials/Financials.md +++ b/src/Financials/Financials.md @@ -16,21 +16,7 @@ require: > see https://github.com/Azure/autorest/blob/master/docs/powershell/directives.md ``` yaml -directive: -# Modify generated .dictionary.cs model classes in Financials module. - - from: source-file-csharp - where: $ - transform: > - if (!$documentPath.match(/generated%5Capi%5CModels%5CMicrosoftGraph\w*\d*.dictionary.cs/gm)) - { - return $; - } else { - // Rename additionalProperties indexer name in Financials module from Item to EntityItem to avoid property name conflict. salesOrderLine has a property named item. - // See https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/indexers/using-indexers - let indexerRegex = /(^\s*)(public\s*global::System.Object this\[global::System.String index\]\s*{\W.*}$)/gm - $ = $.replace(indexerRegex, '$1[System.Runtime.CompilerServices.IndexerName("EntityItem")]\n$1$2'); - return $; - } + ``` ### Versioning From 205b32da153aa9bd50bb138bc7119fa26f826d52 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 12:42:49 -0700 Subject: [PATCH 13/30] Use templates. --- .azure-pipelines/ci-build.yml | 52 ++---------------- .../common-templates/install-tools.yml | 55 +++++++++++++++++++ .../common-templates/security-post-checks.yml | 53 ++++++++++++++++++ .../common-templates/security-pre-checks.yml | 21 +++++++ .../authentication-module.yml | 20 +++++++ .../generation-templates/meta-module.yml | 12 ++++ .../generation-templates/workload-modules.yml | 20 +++++++ 7 files changed, 187 insertions(+), 46 deletions(-) create mode 100644 .azure-pipelines/common-templates/install-tools.yml create mode 100644 .azure-pipelines/common-templates/security-post-checks.yml create mode 100644 .azure-pipelines/common-templates/security-pre-checks.yml create mode 100644 .azure-pipelines/generation-templates/authentication-module.yml create mode 100644 .azure-pipelines/generation-templates/meta-module.yml create mode 100644 .azure-pipelines/generation-templates/workload-modules.yml diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 9c9089fc32b..770a01ffb67 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -25,49 +25,9 @@ jobs: displayName: Microsoft Graph PowerShell SDK CI Build timeoutInMinutes: 840 steps: - - template: ./common-templates/install-tools-template.yml - - template: ./common-templates/security-prechecks-template.yml - # TODO: Load from templates. - # Authentication module. - - task: PowerShell@2 - displayName: Generate Authentication Module - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build - - - task: PowerShell@2 - displayName: Test Authentication Module - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test - # Workload modules. - - task: PowerShell@2 - displayName: Generate Workload Modules - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -ExcludeExampleTemplates -ExcludeNotesSection - - - task: PowerShell@2 - displayName: Test Workload Modules - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test - # Meta-Module module. - - task: PowerShell@2 - displayName: 'Generate Meta-Module' - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 + - template: ./common-templates/install-tools.yml + - template: ./common-templates/security-pre-checks.yml + - template: ./generation-templates/authentication-module.yml + - template: ./generation-templates/workload-modules.yml + - template: ./generation-templates/meta-module.yml + - template: ./common-templates/security-post-checks.yml diff --git a/.azure-pipelines/common-templates/install-tools.yml b/.azure-pipelines/common-templates/install-tools.yml new file mode 100644 index 00000000000..3e5b1914335 --- /dev/null +++ b/.azure-pipelines/common-templates/install-tools.yml @@ -0,0 +1,55 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +steps: + - task: UseDotNet@2 + displayName: Use .NET SDK + inputs: + debugMode: false + version: 6.x + + - task: NuGetToolInstaller@1 + displayName: Install Nuget + + - task: NuGetAuthenticate@0 + + - task: PowerShell@2 + displayName: Version Check + inputs: + targetType: inline + pwsh: true + script: | + Write-Output $PSVersionTable + + - task: NodeTool@0 + displayName: Install NodeJs + inputs: + versionSpec: 16.x + + - task: Npm@1 + displayName: Install AutoRest + inputs: + command: custom + customCommand: install -g autorest@latest + + - task: PowerShell@2 + displayName: Register PS Repository + enabled: false + inputs: + targetType: inline + pwsh: true + errorActionPreference: continue + script: | + $ErrorActionPreference = [System.Management.Automation.ActionPreference]::Continue + Get-PSRepository + $patToken = '$(NUGETFEEDKEY)' | ConvertTo-SecureString -AsPlainText -Force + $nugetFeed = '$(NUGETFEED)' + $user = '$(NUGETBUILDUSER)' + $credsAzureDevopsServices = New-Object System.Management.Automation.PSCredential($user, $patToken) + UnRegister-PackageSource -Name 'LocalNugetPackageSource' -ErrorAction Continue + UnRegister-PSRepository -Name 'LocalNugetFeed' -ErrorAction Continue + Register-PackageSource -Name 'LocalNugetPackageSource' -Location $nugetFeed -SkipValidate -Trusted -Verbose -ProviderName 'Nuget' -ErrorAction Continue + Register-PSRepository -Name 'LocalNugetFeed' -SourceLocation $nugetFeed -PublishLocation $nugetFeed -InstallationPolicy Trusted -Credential $credsAzureDevopsServices -PackageManagementProvider 'Nuget' -ErrorAction Continue + Get-PSRepository + Find-Module -Name Microsoft.Graph.Authentication -AllowPrerelease -Credential $credsAzureDevopsServices -AllVersions -Repository 'LocalNugetFeed' + Find-Module -Name Microsoft.Graph.Authentication -AllowPrerelease -Repository 'LocalNugetFeed' diff --git a/.azure-pipelines/common-templates/security-post-checks.yml b/.azure-pipelines/common-templates/security-post-checks.yml new file mode 100644 index 00000000000..1a5903e36f6 --- /dev/null +++ b/.azure-pipelines/common-templates/security-post-checks.yml @@ -0,0 +1,53 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +steps: +- task: CodesignValidation@0 + +- task: SdtReport@1 + displayName: "Security Analysis Report" + continueOnError: true + condition: succeededOrFailed() + inputs: + AllTools: false + APIScan: false + BinSkim: false + BinSkimBreakOn: 'WarningAbove' + CodesignValidation: true + CodesignValidationBreakOn: 'WarningAbove' + CredScan: true + FortifySCA: false + FxCop: false + ModernCop: false + MSRD: false + PoliCheck: true + PoliCheckBreakOn: 'Severity1' + RoslynAnalyzers: true + RoslynAnalyzersBreakOn: 'WarningAbove' + SDLNativeRules: false + Semmle: false + TSLint: false + TSLintBreakOn: 'WarningAbove' + ToolLogsNotFoundAction: 'Standard' + +- task: PublishSecurityAnalysisLogs@3 + displayName: 'Publish Security Analysis Logs' + inputs: + ArtifactName: 'CodeAnalysisLogs' + ArtifactType: 'Container' + AllTools: false + AntiMalware: false + APIScan: false + BinSkim: false + CodesignValidation: true + CredScan: true + FortifySCA: false + FxCop: false + ModernCop: true + MSRD: false + PoliCheck: true + RoslynAnalyzers: true + SDLNativeRules: false + Semmle: false + TSLint: false + WebScout: false + ToolLogsNotFoundAction: 'Standard' \ No newline at end of file diff --git a/.azure-pipelines/common-templates/security-pre-checks.yml b/.azure-pipelines/common-templates/security-pre-checks.yml new file mode 100644 index 00000000000..71cd9b4cdc8 --- /dev/null +++ b/.azure-pipelines/common-templates/security-pre-checks.yml @@ -0,0 +1,21 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +steps: +- task: CredScan@2 + displayName: 'Run CredScan' + inputs: + debugMode: false + batchSize: 20 + toolMajorVersion: 'V2' + searchersFileType: 'Skype' + +- task: PoliCheck@1 + displayName: 'Run PoliCheck' + condition: and(succeeded(), eq(eq(variables['Build.SourceBranch'], 'refs/heads/main'), false)) + inputs: + targetType: F + SOMEnabled: true + optionsFC: 0 + optionsXS: 0 + optionsHMENABLE: 0 + continueOnError: true \ No newline at end of file diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml new file mode 100644 index 00000000000..1af140c17d9 --- /dev/null +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +steps: + - task: PowerShell@2 + displayName: Generate Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build + + - task: PowerShell@2 + displayName: Test Authentication Module + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test \ No newline at end of file diff --git a/.azure-pipelines/generation-templates/meta-module.yml b/.azure-pipelines/generation-templates/meta-module.yml new file mode 100644 index 00000000000..dca54584b69 --- /dev/null +++ b/.azure-pipelines/generation-templates/meta-module.yml @@ -0,0 +1,12 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +steps: + - task: PowerShell@2 + displayName: 'Generate Meta-Module' + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 \ No newline at end of file diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml new file mode 100644 index 00000000000..740d41b4d5c --- /dev/null +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -0,0 +1,20 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +steps: + - task: PowerShell@2 + displayName: Generate Workload Modules + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -ExcludeExampleTemplates -ExcludeNotesSection + + - task: PowerShell@2 + displayName: Test Workload Modules + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test \ No newline at end of file From 0a6db3d96f9ab570e08814d9d59993772e4c9382 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 12:50:56 -0700 Subject: [PATCH 14/30] Opt-in to test. --- .azure-pipelines/ci-build.yml | 2 ++ .../authentication-module.yml | 29 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 770a01ffb67..18b308c0e89 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -28,6 +28,8 @@ jobs: - template: ./common-templates/install-tools.yml - template: ./common-templates/security-pre-checks.yml - template: ./generation-templates/authentication-module.yml + parameters: + Test: false - template: ./generation-templates/workload-modules.yml - template: ./generation-templates/meta-module.yml - template: ./common-templates/security-post-checks.yml diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml index 1af140c17d9..4816b18be5b 100644 --- a/.azure-pipelines/generation-templates/authentication-module.yml +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -1,5 +1,18 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +parameters: + - name: Test + type: boolean + default: true + - name: Build + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true steps: - task: PowerShell@2 @@ -10,11 +23,11 @@ steps: script: | . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build - - task: PowerShell@2 - displayName: Test Authentication Module - enabled: false - inputs: - targetType: inline - pwsh: true - script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test \ No newline at end of file + - ${{ if eq(parameters.Test, true) }}: + - task: PowerShell@2 + displayName: Test Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test \ No newline at end of file From 778fc85aa85d60730a996456ef2647c00c193a2b Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 14:08:11 -0700 Subject: [PATCH 15/30] Enable signing. --- .../common-templates/esrp/codesign-nuget.yml | 38 ++++++++++++ .../common-templates/esrp/codesign.yml | 59 +++++++++++++++++++ .../common-templates/esrp/strongname.yml | 38 ++++++++++++ .../authentication-module.yml | 14 ++++- .../generation-templates/meta-module.yml | 22 ++++++- .../generation-templates/workload-modules.yml | 27 ++++++++- 6 files changed, 195 insertions(+), 3 deletions(-) create mode 100644 .azure-pipelines/common-templates/esrp/codesign-nuget.yml create mode 100644 .azure-pipelines/common-templates/esrp/codesign.yml create mode 100644 .azure-pipelines/common-templates/esrp/strongname.yml diff --git a/.azure-pipelines/common-templates/esrp/codesign-nuget.yml b/.azure-pipelines/common-templates/esrp/codesign-nuget.yml new file mode 100644 index 00000000000..fc0b8d9e446 --- /dev/null +++ b/.azure-pipelines/common-templates/esrp/codesign-nuget.yml @@ -0,0 +1,38 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +parameters: + - name: FolderPath + type: string + default: $(System.DefaultWorkingDirectory) + - name: Pattern + type: string + default: '*.nupkg' + +steps: + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: ESRP NuGet CodeSigning + enabled: true + inputs: + ConnectedServiceName: microsoftgraph ESRP CodeSign DLL and NuGet (AKV) + FolderPath: ${{ parameters.FolderPath }} + Pattern: ${{ parameters.Pattern }} + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetSign", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetVerify", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + SessionTimeout: 20 diff --git a/.azure-pipelines/common-templates/esrp/codesign.yml b/.azure-pipelines/common-templates/esrp/codesign.yml new file mode 100644 index 00000000000..4f490ae34bc --- /dev/null +++ b/.azure-pipelines/common-templates/esrp/codesign.yml @@ -0,0 +1,59 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +parameters: + - name: FolderPath + type: string + default: $(System.DefaultWorkingDirectory) + - name: Pattern + type: string + default: '.*.dll' + +steps: + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: ESRP DLL CodeSigning + enabled: true + inputs: + ConnectedServiceName: microsoftgraph ESRP CodeSign DLL and NuGet (AKV) + FolderPath: ${{ parameters.FolderPath }} + Pattern: ${{ parameters.Pattern }} + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + SessionTimeout: 160 diff --git a/.azure-pipelines/common-templates/esrp/strongname.yml b/.azure-pipelines/common-templates/esrp/strongname.yml new file mode 100644 index 00000000000..cabe18aab84 --- /dev/null +++ b/.azure-pipelines/common-templates/esrp/strongname.yml @@ -0,0 +1,38 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +parameters: + - name: FolderPath + type: string + default: $(System.DefaultWorkingDirectory) + - name: Pattern + type: string + default: '.*.dll' + +steps: + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: ESRP DLL Strong Name + enabled: true + inputs: + ConnectedServiceName: microsoftgraph ESRP CodeSign DLL and NuGet (AKV) + FolderPath: ${{ parameters.FolderPath }} + Pattern: ${{ parameters.Pattern }} + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "keyCode": "CP-233863-SN", + "operationSetCode": "StrongNameSign", + "parameters": [], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-233863-SN", + "operationSetCode": "StrongNameVerify", + "parameters": [], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + SessionTimeout: 20 diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml index 4816b18be5b..52bf7dc0a47 100644 --- a/.azure-pipelines/generation-templates/authentication-module.yml +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -1,5 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. + parameters: - name: Test type: boolean @@ -30,4 +31,15 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test \ No newline at end of file + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test + + - ${{ if eq(parameters.Sign, true) }}: + - template: ../common-templates/esrp/strongname.yml + parameters: + FolderPath: '$(System.DefaultWorkingDirectory)/Authentication/Authentication' + Pattern: 'Microsoft.Graph.Authentication.dll, Microsoft.Graph.Authentication.Core.dll' + + - template: ../common-templates/esrp/codesign.yml + parameters: + FolderPath: '$(System.DefaultWorkingDirectory)/Authentication/Authentication' + Pattern: 'Microsoft.Graph.Authentication.dll, Microsoft.Graph.Authentication.Core.dll, *.ps1' diff --git a/.azure-pipelines/generation-templates/meta-module.yml b/.azure-pipelines/generation-templates/meta-module.yml index dca54584b69..c45ce3591cf 100644 --- a/.azure-pipelines/generation-templates/meta-module.yml +++ b/.azure-pipelines/generation-templates/meta-module.yml @@ -1,6 +1,20 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +parameters: + - name: Test + type: boolean + default: true + - name: Build + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true + steps: - task: PowerShell@2 displayName: 'Generate Meta-Module' @@ -9,4 +23,10 @@ steps: targetType: inline pwsh: true script: | - $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 \ No newline at end of file + $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 + + - ${{ if eq(parameters.Sign, true) }}: + - template: ../common-templates/esrp/codesign.yml + parameters: + FolderPath: '$(System.DefaultWorkingDirectory)/src/Graph' + Pattern: 'Microsoft.Graph.psm1, Microsoft.Graph.*.format.ps1xml, *.ps1' diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml index 740d41b4d5c..a8b9626668d 100644 --- a/.azure-pipelines/generation-templates/workload-modules.yml +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -1,6 +1,20 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. +parameters: + - name: Test + type: boolean + default: true + - name: Build + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true + steps: - task: PowerShell@2 displayName: Generate Workload Modules @@ -17,4 +31,15 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test \ No newline at end of file + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Test + + - ${{ if eq(parameters.Sign, true) }}: + - template: ../common-templates/esrp/strongname.yml + parameters: + FolderPath: '$(System.DefaultWorkingDirectory)/src' + Pattern: 'Microsoft.Graph.*.private.dll' + + - template: ../common-templates/esrp/codesign.yml + parameters: + FolderPath: '$(System.DefaultWorkingDirectory)/src' + Pattern: 'Microsoft.Graph.*.private.dll, Microsoft.Graph.*.psm1, Microsoft.Graph.*.format.ps1xml, ProxyCmdletDefinitions.ps1, load-dependency.ps1' From f9632de53bd35d5c38c311a8c58a4edff35b48a6 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 14:09:04 -0700 Subject: [PATCH 16/30] Enable test modules. --- config/ModulesMapping.jsonc | 68 ++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index c5fafe6bcbe..b7c3d58087b 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -1,40 +1,40 @@ { "Applications": "^applicationTemplates\\.|^applications\\.|^servicePrincipals\\.|^onPremisesPublishingProfiles\\.|^users.appRoleAssignment$|^groups.appRoleAssignment$", - "Bookings": "^solutions\\.|^bookingBusinesses\\.|^bookingCurrencies\\.", - "Calendar": "^places\\.|^users.calendar$|^users.calendarGroup$|^users.event$|^groups.calendar$|^groups.event$", - "ChangeNotifications": "^subscriptions\\.", - "CloudCommunications": "^users.onlineMeeting$|^users.presence$|^communications\\.", - "Compliance": "^compliance\\.", - "CrossDeviceExperiences": "^users.userActivity$|^users.device$", - "Devices.CloudPrint": "^print\\.", - "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", - "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", - "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", - "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", - // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", - // "DeviceManagement.Actions": "^deviceManagement.Actions$", - // "DeviceManagement.Functions": "^deviceManagement.Functions$", - "DirectoryObjects": "^directoryObjects\\.", - "Education": "^education\\.", - "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", - "Financials": "^financials\\.", - "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", - "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", - "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", - "Identity.SignIns": "^organization.certificateBasedAuthConfiguration$|^invitations\\.|^identityProviders\\.|^oauth2PermissionGrants\\.|^identityProtection\\.|^dataPolicyOperations\\.|^identity.identityUserFlow$|^trustFramework\\.|^informationProtection\\.|^policies\\.|^users.authentication$|^users.informationProtection$|^identity.conditionalAccessRoot$", - "Mail": "^users.inferenceClassification$|^users.mailFolder$|^users.message$", - "Notes": "^users.onenote$|^groups.onenote$|^sites.onenote$", - "People": "^users.person$|^users.profile$|^users.officeGraphInsights$|^users.userAnalytics$", - "PersonalContacts": "^users.contactFolder$|^users.contact$", - "Planner": "^planner\\.|^users.plannerUser$|^groups.plannerGroup$", - "Reports": "^reports\\.|^auditLogs\\.|^deviceManagement.deviceManagementReports$", - "SchemaExtensions": "^schemaExtensions\\.", + // "Bookings": "^solutions\\.|^bookingBusinesses\\.|^bookingCurrencies\\.", + // "Calendar": "^places\\.|^users.calendar$|^users.calendarGroup$|^users.event$|^groups.calendar$|^groups.event$", + // "ChangeNotifications": "^subscriptions\\.", + // "CloudCommunications": "^users.onlineMeeting$|^users.presence$|^communications\\.", + // "Compliance": "^compliance\\.", + // "CrossDeviceExperiences": "^users.userActivity$|^users.device$", + // "Devices.CloudPrint": "^print\\.", + // "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", + // "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", + // "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", + // "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", + // // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", + // // "DeviceManagement.Actions": "^deviceManagement.Actions$", + // // "DeviceManagement.Functions": "^deviceManagement.Functions$", + // "DirectoryObjects": "^directoryObjects\\.", + // "Education": "^education\\.", + // "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", + // "Financials": "^financials\\.", + // "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", + // "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", + // "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", + // "Identity.SignIns": "^organization.certificateBasedAuthConfiguration$|^invitations\\.|^identityProviders\\.|^oauth2PermissionGrants\\.|^identityProtection\\.|^dataPolicyOperations\\.|^identity.identityUserFlow$|^trustFramework\\.|^informationProtection\\.|^policies\\.|^users.authentication$|^users.informationProtection$|^identity.conditionalAccessRoot$", + // "Mail": "^users.inferenceClassification$|^users.mailFolder$|^users.message$", + // "Notes": "^users.onenote$|^groups.onenote$|^sites.onenote$", + // "People": "^users.person$|^users.profile$|^users.officeGraphInsights$|^users.userAnalytics$", + // "PersonalContacts": "^users.contactFolder$|^users.contact$", + // "Planner": "^planner\\.|^users.plannerUser$|^groups.plannerGroup$", + // "Reports": "^reports\\.|^auditLogs\\.|^deviceManagement.deviceManagementReports$", + // "SchemaExtensions": "^schemaExtensions\\.", "Search": "^search\\.|^external\\.", "Security": "^security\\.", - "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", - // "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", - "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", - "Users.Actions": "^users.Actions$", - // "Users.Functions": "^users.Functions$", + // "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", + // // "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", + // "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", + // "Users.Actions": "^users.Actions$", + // // "Users.Functions": "^users.Functions$", "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" } \ No newline at end of file From 81706a7e3f86661ca84b051066c63675d1a9d74a Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 14:24:41 -0700 Subject: [PATCH 17/30] Update folder path. --- .../generation-templates/authentication-module.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml index 52bf7dc0a47..ba9c9aa84fd 100644 --- a/.azure-pipelines/generation-templates/authentication-module.yml +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -36,10 +36,10 @@ steps: - ${{ if eq(parameters.Sign, true) }}: - template: ../common-templates/esrp/strongname.yml parameters: - FolderPath: '$(System.DefaultWorkingDirectory)/Authentication/Authentication' + FolderPath: '$(System.DefaultWorkingDirectory)/src/Authentication/Authentication' Pattern: 'Microsoft.Graph.Authentication.dll, Microsoft.Graph.Authentication.Core.dll' - template: ../common-templates/esrp/codesign.yml parameters: - FolderPath: '$(System.DefaultWorkingDirectory)/Authentication/Authentication' + FolderPath: '$(System.DefaultWorkingDirectory)/src/Authentication/Authentication' Pattern: 'Microsoft.Graph.Authentication.dll, Microsoft.Graph.Authentication.Core.dll, *.ps1' From 981f6e49aeb71b8ec4efeae0d498fdf6c864e894 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 15:23:16 -0700 Subject: [PATCH 18/30] Enable signing. --- .azure-pipelines/generation-templates/authentication-module.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml index ba9c9aa84fd..4b7e6833b41 100644 --- a/.azure-pipelines/generation-templates/authentication-module.yml +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -22,7 +22,7 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Build + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -EnableSigning:$${{ parameters.Sign }} -Build - ${{ if eq(parameters.Test, true) }}: - task: PowerShell@2 From d459665ddbdfe01a987a5fe32ceb31d85c5097c5 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 15:32:38 -0700 Subject: [PATCH 19/30] Set signing option for templates. --- .azure-pipelines/ci-build.yml | 6 ++++++ .../generation-templates/authentication-module.yml | 12 +++++++++--- .../generation-templates/meta-module.yml | 12 +++++++++--- .../generation-templates/workload-modules.yml | 12 +++++++++--- 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 18b308c0e89..6183a03a670 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -31,5 +31,11 @@ jobs: parameters: Test: false - template: ./generation-templates/workload-modules.yml + parameters: + Test: false + Sign: false - template: ./generation-templates/meta-module.yml + parameters: + Test: false + Sign: false - template: ./common-templates/security-post-checks.yml diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml index 4b7e6833b41..58e124317a7 100644 --- a/.azure-pipelines/generation-templates/authentication-module.yml +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -5,9 +5,6 @@ parameters: - name: Test type: boolean default: true - - name: Build - type: boolean - default: true - name: Pack type: boolean default: true @@ -43,3 +40,12 @@ steps: parameters: FolderPath: '$(System.DefaultWorkingDirectory)/src/Authentication/Authentication' Pattern: 'Microsoft.Graph.Authentication.dll, Microsoft.Graph.Authentication.Core.dll, *.ps1' + + - ${{ if eq(parameters.Pack, true) }}: + - task: PowerShell@2 + displayName: Pack Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Pack diff --git a/.azure-pipelines/generation-templates/meta-module.yml b/.azure-pipelines/generation-templates/meta-module.yml index c45ce3591cf..18f3c8f2f88 100644 --- a/.azure-pipelines/generation-templates/meta-module.yml +++ b/.azure-pipelines/generation-templates/meta-module.yml @@ -5,9 +5,6 @@ parameters: - name: Test type: boolean default: true - - name: Build - type: boolean - default: true - name: Pack type: boolean default: true @@ -30,3 +27,12 @@ steps: parameters: FolderPath: '$(System.DefaultWorkingDirectory)/src/Graph' Pattern: 'Microsoft.Graph.psm1, Microsoft.Graph.*.format.ps1xml, *.ps1' + + - ${{ if eq(parameters.Pack, true) }}: + - task: PowerShell@2 + displayName: Pack Meta-Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 -Pack diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml index a8b9626668d..aeacbc0cba6 100644 --- a/.azure-pipelines/generation-templates/workload-modules.yml +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -5,9 +5,6 @@ parameters: - name: Test type: boolean default: true - - name: Build - type: boolean - default: true - name: Pack type: boolean default: true @@ -43,3 +40,12 @@ steps: parameters: FolderPath: '$(System.DefaultWorkingDirectory)/src' Pattern: 'Microsoft.Graph.*.private.dll, Microsoft.Graph.*.psm1, Microsoft.Graph.*.format.ps1xml, ProxyCmdletDefinitions.ps1, load-dependency.ps1' + + - ${{ if eq(parameters.Pack, true) }}: + - task: PowerShell@2 + displayName: Pack Workload Modules + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Pack From 9e700983ae5d345eacc322fa29b39520c310c03e Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 16:23:02 -0700 Subject: [PATCH 20/30] Publish module to artifact directory. --- .azure-pipelines/ci-build.yml | 40 ++++++++++++++++--- .../authentication-module.yml | 2 +- .../generation-templates/meta-module.yml | 2 +- .../generation-templates/workload-modules.yml | 4 +- config/ModulesMapping.jsonc | 6 +-- tools/GenerateModules.ps1 | 2 +- tools/GenerateRollUpModule.ps1 | 2 +- 7 files changed, 44 insertions(+), 14 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 6183a03a670..a61fff4b678 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -5,6 +5,15 @@ parameters: - name: BuildAgent default: 1es-windows-ps-compute displayName: Build Agent + - name: Test + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true variables: BuildAgent: ${{ parameters.BuildAgent }} @@ -27,15 +36,36 @@ jobs: steps: - template: ./common-templates/install-tools.yml - template: ./common-templates/security-pre-checks.yml + - template: ./generation-templates/authentication-module.yml parameters: - Test: false + Test: ${{ parameters.Test }} + Pack: ${{ parameters.Pack }} + Sign: ${{ parameters.Sign }} + - template: ./generation-templates/workload-modules.yml parameters: - Test: false - Sign: false + Test: ${{ parameters.Test }} + Pack: ${{ parameters.Pack }} + Sign: ${{ parameters.Sign }} + - template: ./generation-templates/meta-module.yml parameters: - Test: false - Sign: false + Test: ${{ parameters.Test }} + Pack: ${{ parameters.Pack }} + Sign: ${{ parameters.Sign }} + + - ${{ if eq(parameters.Sign, true) }}: + - template: ./common-templates/esrp/codesign-nuget.yml + parameters: + FolderPath: '$(Build.ArtifactStagingDirectory)' + Pattern: 'Microsoft.Graph*.nupkg' + + - task: PublishBuildArtifacts@1 + displayName: Publish Module Artifacts + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)' + ArtifactName: 'drop' + publishLocation: 'Container' + - template: ./common-templates/security-post-checks.yml diff --git a/.azure-pipelines/generation-templates/authentication-module.yml b/.azure-pipelines/generation-templates/authentication-module.yml index 58e124317a7..bec02c4a8cf 100644 --- a/.azure-pipelines/generation-templates/authentication-module.yml +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -48,4 +48,4 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Pack + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/.azure-pipelines/generation-templates/meta-module.yml b/.azure-pipelines/generation-templates/meta-module.yml index 18f3c8f2f88..d2891079c47 100644 --- a/.azure-pipelines/generation-templates/meta-module.yml +++ b/.azure-pipelines/generation-templates/meta-module.yml @@ -35,4 +35,4 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 -Pack + . $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml index aeacbc0cba6..dddf5804936 100644 --- a/.azure-pipelines/generation-templates/workload-modules.yml +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -19,7 +19,7 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -Build -ExcludeExampleTemplates -ExcludeNotesSection + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -EnableSigning:$${{ parameters.Sign }} -Build -ExcludeExampleTemplates -ExcludeNotesSection - task: PowerShell@2 displayName: Test Workload Modules @@ -48,4 +48,4 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Pack + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -SkipGeneration -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index b7c3d58087b..4c18350b4ba 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -1,5 +1,5 @@ { - "Applications": "^applicationTemplates\\.|^applications\\.|^servicePrincipals\\.|^onPremisesPublishingProfiles\\.|^users.appRoleAssignment$|^groups.appRoleAssignment$", + // "Applications": "^applicationTemplates\\.|^applications\\.|^servicePrincipals\\.|^onPremisesPublishingProfiles\\.|^users.appRoleAssignment$|^groups.appRoleAssignment$", // "Bookings": "^solutions\\.|^bookingBusinesses\\.|^bookingCurrencies\\.", // "Calendar": "^places\\.|^users.calendar$|^users.calendarGroup$|^users.event$|^groups.calendar$|^groups.event$", // "ChangeNotifications": "^subscriptions\\.", @@ -30,11 +30,11 @@ // "Reports": "^reports\\.|^auditLogs\\.|^deviceManagement.deviceManagementReports$", // "SchemaExtensions": "^schemaExtensions\\.", "Search": "^search\\.|^external\\.", - "Security": "^security\\.", + // "Security": "^security\\.", // "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", // // "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", // "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", // "Users.Actions": "^users.Actions$", // // "Users.Functions": "^users.Functions$", - "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" + // "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" } \ No newline at end of file diff --git a/tools/GenerateModules.ps1 b/tools/GenerateModules.ps1 index 23dbe22754d..641a96264e2 100644 --- a/tools/GenerateModules.ps1 +++ b/tools/GenerateModules.ps1 @@ -6,6 +6,7 @@ Param( [ValidateSet("v1.0", "beta")] $ApiVersionToGenerate = @("v1.0", "beta"), [string] $RepositoryName = "PSGallery", + [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), [int] $ModulePreviewNumber = -1, [switch] $SkipGeneration = $false, [switch] $Build, @@ -43,7 +44,6 @@ $ENV:NODE_OPTIONS = "--max-old-space-size=$MaxMemorySize" $ModulePrefix = "Microsoft.Graph" $ScriptRoot = $PSScriptRoot $ModulesOutputPath = Join-Path $ScriptRoot "..\src\" -$ArtifactsLocation = Join-Path $ScriptRoot "..\artifacts" $OpenApiPath = Join-Path $ScriptRoot "..\openApiDocs" $TemplatePath = Join-Path $ScriptRoot "\Templates\" $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc") diff --git a/tools/GenerateRollUpModule.ps1 b/tools/GenerateRollUpModule.ps1 index f841c62a1f0..4478aef1e01 100644 --- a/tools/GenerateRollUpModule.ps1 +++ b/tools/GenerateRollUpModule.ps1 @@ -5,6 +5,7 @@ Param( [string] $RepositoryApiKey, [string] $RepositoryName = "PSGallery", + [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), [string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc"), [int] $ModulePreviewNumber = -1, [switch] $Pack, @@ -31,7 +32,6 @@ $NuspecHelperPS1 = Join-Path $PSScriptRoot ".\NuspecHelper.ps1" $PublishModulePS1 = Join-Path $PSScriptRoot ".\PublishModule.ps1" -Resolve $ValidateUpdatedModuleVersionPS1 = Join-Path $PSScriptRoot ".\ValidateUpdatedModuleVersion.ps1" -Resolve $ModuleMetadataJson = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -Resolve -$ArtifactsLocation = Join-Path $PSScriptRoot "..\artifacts\" $GraphModuleLocation = Join-Path $PSScriptRoot "..\src\Graph\Graph" $RollUpModuleNuspec = Join-Path $GraphModuleLocation ".\$ModulePrefix" $RequiredGraphModules = @() From 83065a11ab9dbdec665f0c7ddaf0c4b0122018c9 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 16:29:18 -0700 Subject: [PATCH 21/30] Publish to drop container on pack and sign. --- .azure-pipelines/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index a61fff4b678..7931bdefd85 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -55,7 +55,7 @@ jobs: Pack: ${{ parameters.Pack }} Sign: ${{ parameters.Sign }} - - ${{ if eq(parameters.Sign, true) }}: + - ${{ if and(eq(parameters.Pack, true), eq(parameters.Sign, true)) }}: - template: ./common-templates/esrp/codesign-nuget.yml parameters: FolderPath: '$(Build.ArtifactStagingDirectory)' From 03c1c902b04e6c9626d598516695966840b0d6fe Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 20 Jul 2022 16:57:03 -0700 Subject: [PATCH 22/30] Enable all succeeding modules. --- config/ModulesMapping.jsonc | 74 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 4c18350b4ba..c5fafe6bcbe 100644 --- a/config/ModulesMapping.jsonc +++ b/config/ModulesMapping.jsonc @@ -1,40 +1,40 @@ { - // "Applications": "^applicationTemplates\\.|^applications\\.|^servicePrincipals\\.|^onPremisesPublishingProfiles\\.|^users.appRoleAssignment$|^groups.appRoleAssignment$", - // "Bookings": "^solutions\\.|^bookingBusinesses\\.|^bookingCurrencies\\.", - // "Calendar": "^places\\.|^users.calendar$|^users.calendarGroup$|^users.event$|^groups.calendar$|^groups.event$", - // "ChangeNotifications": "^subscriptions\\.", - // "CloudCommunications": "^users.onlineMeeting$|^users.presence$|^communications\\.", - // "Compliance": "^compliance\\.", - // "CrossDeviceExperiences": "^users.userActivity$|^users.device$", - // "Devices.CloudPrint": "^print\\.", - // "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", - // "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", - // "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", - // "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", - // // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", - // // "DeviceManagement.Actions": "^deviceManagement.Actions$", - // // "DeviceManagement.Functions": "^deviceManagement.Functions$", - // "DirectoryObjects": "^directoryObjects\\.", - // "Education": "^education\\.", - // "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", - // "Financials": "^financials\\.", - // "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", - // "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", - // "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", - // "Identity.SignIns": "^organization.certificateBasedAuthConfiguration$|^invitations\\.|^identityProviders\\.|^oauth2PermissionGrants\\.|^identityProtection\\.|^dataPolicyOperations\\.|^identity.identityUserFlow$|^trustFramework\\.|^informationProtection\\.|^policies\\.|^users.authentication$|^users.informationProtection$|^identity.conditionalAccessRoot$", - // "Mail": "^users.inferenceClassification$|^users.mailFolder$|^users.message$", - // "Notes": "^users.onenote$|^groups.onenote$|^sites.onenote$", - // "People": "^users.person$|^users.profile$|^users.officeGraphInsights$|^users.userAnalytics$", - // "PersonalContacts": "^users.contactFolder$|^users.contact$", - // "Planner": "^planner\\.|^users.plannerUser$|^groups.plannerGroup$", - // "Reports": "^reports\\.|^auditLogs\\.|^deviceManagement.deviceManagementReports$", - // "SchemaExtensions": "^schemaExtensions\\.", + "Applications": "^applicationTemplates\\.|^applications\\.|^servicePrincipals\\.|^onPremisesPublishingProfiles\\.|^users.appRoleAssignment$|^groups.appRoleAssignment$", + "Bookings": "^solutions\\.|^bookingBusinesses\\.|^bookingCurrencies\\.", + "Calendar": "^places\\.|^users.calendar$|^users.calendarGroup$|^users.event$|^groups.calendar$|^groups.event$", + "ChangeNotifications": "^subscriptions\\.", + "CloudCommunications": "^users.onlineMeeting$|^users.presence$|^communications\\.", + "Compliance": "^compliance\\.", + "CrossDeviceExperiences": "^users.userActivity$|^users.device$", + "Devices.CloudPrint": "^print\\.", + "Devices.CorporateManagement": "^deviceAppManagement\\.|^officeConfiguration\\.|^users.mobileAppIntentAndState$|^users.mobileAppTroubleshootingEvent$|^users.windowsInformationProtectionDeviceRegistration$|^users.managedAppRegistration$|^users.managedDevice$|^users.deviceManagementTroubleshootingEvent$|^users.deviceEnrollmentConfiguration$", + "Devices.ServiceAnnouncement": "^admin.serviceAnnouncement$|^admin.Actions$|^admin.Functions$", + "DeviceManagement": "^deviceManagement.(deviceCompliancePolicy.*|deviceManagementConfigurationPolicy.*|deviceManagementCompliancePolicy.*|deviceManagementConfigurationSettingDefinition.*|deviceConfiguration.*|managedDevice.*|managementCondition.*|microsoftTunnel.*|userExperienceAnalytics.*|windowsInformationProtection.*|deviceManagement|deviceManagement(DerivedCredentialSettings|Intent|ResourceAccessProfileBase|Script|SettingCategory|SettingDefinition|Template|TroubleshootingEvent)|androidForWork(AppConfigurationSchema|Settings)|androidManagedStore(AccountEnterpriseSettings|AppConfigurationSchema)|deviceAndAppManagementAssignmentFilter|deviceCategory|advancedThreatProtectionOnboardingStateSummary|dataSharingConsent|detectedApp|deviceHealthScript|deviceShellScript|embeddedSIMActivationCodePool|groupPolicyConfiguration|macOSSoftwareUpdateAccountSummary|mobileAppTroubleshootingEvent|notificationMessageTemplate|remoteActionAudit|softwareUpdateStatusSummary|windowsMalwareInformation)$", + "DeviceManagement.Administration": "^deviceManagement.(virtualEndpoint.*|.*Partner.*|.*Certificate.*|.*role.*|deviceManagement(DomainJoinConnector|ExchangeConnector|ExchangeOnPremisesPolicy)|groupPolicy(Category|Definition|DefinitionFile|MigrationReport|ObjectFile|UploadedDefinitionFile)|auditEvent|cartToClassAssociation|comanagementEligibleDevice|deviceAndAppManagementRoleAssignment|intuneBrandingProfile|iosUpdateDeviceStatus|mobileThreatDefenseConnector|ndesConnector|resourceOperation|restrictedAppsViolation|termsAndConditions)", + // "DeviceManagement.Enrolment": "^deviceManagement.(.*Enrollment.*|.*Autopilot.*|.*depOnboarding.*|importedDeviceIdentity|onPremisesConditionalAccessSettings|windowsFeatureUpdateProfile)$|^roleManagement\\.", + // "DeviceManagement.Actions": "^deviceManagement.Actions$", + // "DeviceManagement.Functions": "^deviceManagement.Functions$", + "DirectoryObjects": "^directoryObjects\\.", + "Education": "^education\\.", + "Files": "^drives\\.|^shares\\.|^users.drive$|^groups.drive$", + "Financials": "^financials\\.", + "Groups": "^groups.group$|^groups.directoryObject$|^groups.conversation$|^groups.endpoint$|^groups.extension$|^groups.resourceSpecificPermissionGrant$|^groups.profilePhoto$|^groups.conversationThread$|^groupLifecyclePolicies\\.|^users.group$|^groups.directorySetting$|^groups.Actions$|^groups.Functions$", + "Identity.DirectoryManagement": "^administrativeUnits\\.|^contacts\\.|^devices\\.|^domains\\.|^directoryRoles\\.|^directoryRoleTemplates\\.|^directorySettingTemplates\\.|^settings\\.|^subscribedSkus\\.|^contracts\\.|^directory\\.|^users.scopedRoleMembership$|^organization.organization$|^organization.organizationalBranding$|^organization.organizationSettings$|^organization.Actions$|^organization.extension$", + "Identity.Governance": "^accessReviews\\.|^businessFlowTemplates\\.|^programs\\.|^programControls\\.|^programControlTypes\\.|^privilegedRoles\\.|^privilegedRoleAssignments\\.|^privilegedRoleAssignmentRequests\\.|^privilegedApproval\\.|^privilegedOperationEvents\\.|^privilegedAccess\\.|^agreements\\.|^users.agreementAcceptance$|^identityGovernance\\.", + "Identity.SignIns": "^organization.certificateBasedAuthConfiguration$|^invitations\\.|^identityProviders\\.|^oauth2PermissionGrants\\.|^identityProtection\\.|^dataPolicyOperations\\.|^identity.identityUserFlow$|^trustFramework\\.|^informationProtection\\.|^policies\\.|^users.authentication$|^users.informationProtection$|^identity.conditionalAccessRoot$", + "Mail": "^users.inferenceClassification$|^users.mailFolder$|^users.message$", + "Notes": "^users.onenote$|^groups.onenote$|^sites.onenote$", + "People": "^users.person$|^users.profile$|^users.officeGraphInsights$|^users.userAnalytics$", + "PersonalContacts": "^users.contactFolder$|^users.contact$", + "Planner": "^planner\\.|^users.plannerUser$|^groups.plannerGroup$", + "Reports": "^reports\\.|^auditLogs\\.|^deviceManagement.deviceManagementReports$", + "SchemaExtensions": "^schemaExtensions\\.", "Search": "^search\\.|^external\\.", - // "Security": "^security\\.", - // "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", - // // "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", - // "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", - // "Users.Actions": "^users.Actions$", - // // "Users.Functions": "^users.Functions$", - // "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" + "Security": "^security\\.", + "Sites": "^sites.site$|^sites.itemAnalytics$|^sites.columnDefinition$|^sites.contentType$|^sites.drive$|^sites.list$|^sites.sitePage$|^sites.permission$|^sites.store$|^users.site$|^groups.site$|^sites.Functions$|^sites.Actions$", + // "Teams": "^teams\\.|^chats\\.|^users.chat$|^appCatalogs.teamsApp$|^users.userTeamwork$|^teamwork\\.|^users.team$|^groups.team$", + "Users": "^users.user$|^users.directoryObject$|^users.licenseDetails$|^users.notification$|^users.outlookUser$|^users.profilePhoto$|^users.userSettings$|^users.extension$|^users.oAuth2PermissionGrant$|^users.todo$", + "Users.Actions": "^users.Actions$", + // "Users.Functions": "^users.Functions$", + "WindowsUpdates": "^admin.windows$|^admin.Actions$|^admin.Functions$" } \ No newline at end of file From ecfd8845fc18bfa2faaaba1a8e93cd559bcf93be Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 21 Jul 2022 14:00:40 -0700 Subject: [PATCH 23/30] Publish to feed. --- .azure-pipelines/ci-build.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 7931bdefd85..4d43a245465 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -68,4 +68,12 @@ jobs: ArtifactName: 'drop' publishLocation: 'Container' + - task: NuGetCommand@2 + displayName: Publish NuGet to preview feed + inputs: + command: push + packagesToPush: $(Build.ArtifactStagingDirectory)/**/Microsoft.Graph.*.nupkg + publishVstsFeed: $(PROJECT_NAME)/$(PREVIEW_FEED_NAME) + allowPackageConflicts: true + - template: ./common-templates/security-post-checks.yml From 6504da74f389b527b7045860308874202196bc40 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 22 Jul 2022 12:12:13 -0700 Subject: [PATCH 24/30] Enable packing of meta-module. --- .../generation-templates/meta-module.yml | 4 +- src/Graph/beta/Microsoft.Graph.Beta.nuspec | 22 +++ src/Graph/beta/Microsoft.Graph.Beta.psd1 | 136 ++++++++++++++ src/Graph/v1.0/Microsoft.Graph.nuspec | 21 +++ src/Graph/v1.0/Microsoft.Graph.psd1 | 135 ++++++++++++++ tools/GenerateMetaModule.ps1 | 168 ++++++++++++++++++ tools/GenerateModules.ps1 | 19 +- 7 files changed, 493 insertions(+), 12 deletions(-) create mode 100644 src/Graph/beta/Microsoft.Graph.Beta.nuspec create mode 100644 src/Graph/beta/Microsoft.Graph.Beta.psd1 create mode 100644 src/Graph/v1.0/Microsoft.Graph.nuspec create mode 100644 src/Graph/v1.0/Microsoft.Graph.psd1 create mode 100644 tools/GenerateMetaModule.ps1 diff --git a/.azure-pipelines/generation-templates/meta-module.yml b/.azure-pipelines/generation-templates/meta-module.yml index d2891079c47..7e164d27421 100644 --- a/.azure-pipelines/generation-templates/meta-module.yml +++ b/.azure-pipelines/generation-templates/meta-module.yml @@ -20,7 +20,7 @@ steps: targetType: inline pwsh: true script: | - $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 + $(System.DefaultWorkingDirectory)/tools/GenerateMetaModule.ps1 - ${{ if eq(parameters.Sign, true) }}: - template: ../common-templates/esrp/codesign.yml @@ -35,4 +35,4 @@ steps: targetType: inline pwsh: true script: | - . $(System.DefaultWorkingDirectory)/tools/GenerateRollUpModule.ps1 -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) + . $(System.DefaultWorkingDirectory)/tools/GenerateMetaModule.ps1 -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/src/Graph/beta/Microsoft.Graph.Beta.nuspec b/src/Graph/beta/Microsoft.Graph.Beta.nuspec new file mode 100644 index 00000000000..ee2efca23dd --- /dev/null +++ b/src/Graph/beta/Microsoft.Graph.Beta.nuspec @@ -0,0 +1,22 @@ + + + + Microsoft.Graph.Beta + 1.10.0 + Microsoft + Microsoft + https://aka.ms/devservicesagreement + https://github.com/microsoftgraph/msgraph-sdk-powershell + https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png + true + Microsoft Graph PowerShell module + © Microsoft Corporation. All rights reserved. + MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported + + + + + + See https://aka.ms/GraphPowerShell-Release. + + \ No newline at end of file diff --git a/src/Graph/beta/Microsoft.Graph.Beta.psd1 b/src/Graph/beta/Microsoft.Graph.Beta.psd1 new file mode 100644 index 00000000000..2cdf717dd56 --- /dev/null +++ b/src/Graph/beta/Microsoft.Graph.Beta.psd1 @@ -0,0 +1,136 @@ +# +# Module manifest for module 'Microsoft.Graph.Beta' +# +# Generated by: Microsoft +# +# Generated on: 7/22/2022 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = '1.10.0' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = '5fbd6f8c-b554-439a-a883-be5391e82229' + +# Author of this module +Author = 'Microsoft' + +# Company or vendor of this module +CompanyName = 'Microsoft' + +# Copyright statement for this module +Copyright = '© Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Microsoft Graph PowerShell module' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.7.2' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; RequiredVersion = '1.10.0'; }, + @{ModuleName = 'Microsoft.Graph.Beta.WindowsUpdates'; RequiredVersion = '1.9.6'; }, + @{ModuleName = 'Microsoft.Graph.Beta.Search'; RequiredVersion = '1.9.6'; }) + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# 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. +FunctionsToExport = @() + +# 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. +CmdletsToExport = @() + +# Variables to export from this module +VariablesToExport = '*' + +# 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. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# 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. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'MicrosoftGraph', 'Microsoft', 'Office365', 'Graph', 'PowerShell', + 'Outlook', 'OneDrive', 'AzureAD', 'SharePoint', 'Intune', + 'AzureAutomationNotSupported' + + # A URL to the license for this module. + LicenseUri = 'https://aka.ms/devservicesagreement' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/microsoftgraph/msgraph-sdk-powershell' + + # A URL to an icon representing this module. + IconUri = 'https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png' + + # ReleaseNotes of this module + ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/src/Graph/v1.0/Microsoft.Graph.nuspec b/src/Graph/v1.0/Microsoft.Graph.nuspec new file mode 100644 index 00000000000..607a6a731c9 --- /dev/null +++ b/src/Graph/v1.0/Microsoft.Graph.nuspec @@ -0,0 +1,21 @@ + + + + Microsoft.Graph + 1.10.0 + Microsoft + Microsoft + https://aka.ms/devservicesagreement + https://github.com/microsoftgraph/msgraph-sdk-powershell + https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png + true + Microsoft Graph PowerShell module + © Microsoft Corporation. All rights reserved. + MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported + + + + + See https://aka.ms/GraphPowerShell-Release. + + \ No newline at end of file diff --git a/src/Graph/v1.0/Microsoft.Graph.psd1 b/src/Graph/v1.0/Microsoft.Graph.psd1 new file mode 100644 index 00000000000..e51284d02b8 --- /dev/null +++ b/src/Graph/v1.0/Microsoft.Graph.psd1 @@ -0,0 +1,135 @@ +# +# Module manifest for module 'Microsoft.Graph' +# +# Generated by: Microsoft +# +# Generated on: 7/22/2022 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = '1.10.0' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = 'ed12d535-7fc8-43fe-a135-e04cf5e5daca' + +# Author of this module +Author = 'Microsoft' + +# Company or vendor of this module +CompanyName = 'Microsoft' + +# Copyright statement for this module +Copyright = '© Microsoft Corporation. All rights reserved.' + +# Description of the functionality provided by this module +Description = 'Microsoft Graph PowerShell module' + +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '5.1' + +# Name of the PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +DotNetFrameworkVersion = '4.7.2' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; RequiredVersion = '1.10.0'; }, + @{ModuleName = 'Microsoft.Graph.Search'; RequiredVersion = '1.9.6'; }) + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# 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. +FunctionsToExport = @() + +# 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. +CmdletsToExport = @() + +# Variables to export from this module +VariablesToExport = '*' + +# 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. +AliasesToExport = @() + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# 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. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'MicrosoftGraph', 'Microsoft', 'Office365', 'Graph', 'PowerShell', + 'Outlook', 'OneDrive', 'AzureAD', 'SharePoint', 'Intune', + 'AzureAutomationNotSupported' + + # A URL to the license for this module. + LicenseUri = 'https://aka.ms/devservicesagreement' + + # A URL to the main website for this project. + ProjectUri = 'https://github.com/microsoftgraph/msgraph-sdk-powershell' + + # A URL to an icon representing this module. + IconUri = 'https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png' + + # ReleaseNotes of this module + ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.' + + # Prerelease string of this module + # Prerelease = '' + + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false + + # External dependent modules of this module + # ExternalModuleDependencies = @() + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + diff --git a/tools/GenerateMetaModule.ps1 b/tools/GenerateMetaModule.ps1 new file mode 100644 index 00000000000..73b11790c0d --- /dev/null +++ b/tools/GenerateMetaModule.ps1 @@ -0,0 +1,168 @@ + +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +[CmdletBinding()] +Param( + [ValidateSet("v1.0", "beta")] + $ApiVersion = @("v1.0", "beta"), + [string] $RepositoryApiKey, + [string] $RepositoryName = "PSGallery", + [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), + [string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc"), + [int] $ModulePreviewNumber = -1, + [switch] $Pack, + [switch] $Publish +) +enum VersionState { + Invalid + Valid + EqualToFeed + NotOnFeed +} +$ErrorActionPreference = 'Stop' +$LASTEXITCODE = $null +if ($PSEdition -ne 'Core') { + Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.' +} + +if (-not (Test-Path $ModuleMappingConfigPath)) { + Write-Error "Module mapping file not be found: $ModuleMappingConfigPath." +} + +$ModulePrefix = "Microsoft.Graph" +$NuspecHelperPS1 = Join-Path $PSScriptRoot ".\NuspecHelper.ps1" +$PublishModulePS1 = Join-Path $PSScriptRoot ".\PublishModule.ps1" -Resolve +$ValidateUpdatedModuleVersionPS1 = Join-Path $PSScriptRoot ".\ValidateUpdatedModuleVersion.ps1" -Resolve +$ModuleMetadataJson = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -Resolve +$ModulesSrc = Join-Path $PSScriptRoot "..\src" +$MetaModuleModuleDir = Join-Path $ModulesSrc "Graph" +[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable +[HashTable] $NuspecMetadata = Get-Content $ModuleMetadataJson | ConvertFrom-Json -AsHashTable +$NuspecMetadata.Remove("assemblyOriginatorKeyFile") + +# Import scripts +. $NuspecHelperPS1 + +if ($null -eq $NuspecMetadata["version"]) { + # Module version not set in module manifest (psd1). + Write-Error "Version number is not set on $ModulePrefix module. Please set 'version' in $ModuleMetadataJson." +} + +# Validate module version with the one on PSGallery. +[VersionState]$VersionState = & $ValidateUpdatedModuleVersionPS1 -ModuleName $ModulePrefix -NextVersion $NuspecMetadata["version"] + +if ($VersionState.Equals([VersionState]::Invalid)) { + Write-Warning "The specified version in $ModulePrefix module is either higher or lower than what's on $RepositoryName. Update 'version' in $ModuleMetadataJson." +} +elseif ($VersionState.Equals([VersionState]::EqualToFeed)) { + Write-Warning "$ModulePrefix module skipped. Version has not changed and is equal to what's on $RepositoryName." +} +elseif ($VersionState.Equals([VersionState]::Valid) -or $VersionState.Equals([VersionState]::NotOnFeed)) { + $NuspecMetadata["version"] = $VersionState.Equals([VersionState]::NotOnFeed) ? "0.1.1" : $NuspecMetadata["version"] + + $RollUpModuleArtifactLocation = "$ArtifactsLocation\graph" + if (-not (Test-Path $RollUpModuleArtifactLocation)) { + New-Item -Path $RollUpModuleArtifactLocation -Type Directory + } + else { + Remove-Item -Path "$RollUpModuleArtifactLocation\*" -Recurse -Force + } + + if (-not (Test-Path $MetaModuleModuleDir)) { + New-Item -Path $MetaModuleModuleDir -Type Directory + } + $AllowPreRelease = $true + if ($ModulePreviewNumber -eq -1) { + $AllowPreRelease = $false + } + + [HashTable]$ModuleManifestSettings = @{ + CompatiblePSEditions = "Core", "Desktop" + PowerShellVersion = "5.1" + DotNetFrameworkVersion = "4.7.2" + ModuleVersion = $NuspecMetadata["version"] + Author = $NuspecMetadata["authors"] + CompanyName = $NuspecMetadata["owners"] + Copyright = $NuspecMetadata["copyright"] + Description = $NuspecMetadata["description"] + Tags = $NuspecMetadata["tags"] + LicenseUri = $NuspecMetadata["licenseUri"] + ProjectUri = $NuspecMetadata["projectUri"] + IconUri = $NuspecMetadata["iconUri"] + ReleaseNotes = $NuspecMetadata["releaseNotes"] + RequiredModules = @() + AliasesToExport = @() + CmdletsToExport = @() + FunctionsToExport = @() + } + + # Import authentication module from src folder. + $AuthModuleManifest = Join-Path $ModulesSrc "Authentication" "Authentication" "artifacts" "Microsoft.Graph.Authentication.psd1" + $LoadedAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction SilentlyContinue + + $ApiVersion | ForEach-Object { + $CurrentApiVersion = $_ + $NuspecOptions = $NuspecMetadata.Clone() + $Module = ($CurrentApiVersion -eq "beta" ? "$ModulePrefix.Beta" : $ModulePrefix) + $RequiredGraphModules = @() + if ($null -ne $LoadedAuthModule) { + # TODO: Handle pre release modules. + # $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; RequiredVersion = $LoadedAuthModule.Version; Prerelease = $LoadedAuthModule.Prerelease } + $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; RequiredVersion = $LoadedAuthModule.Version } + } else { + Write-Warning "Module not found in $AuthModuleManifest." + } + + $ModuleMapping.Keys | ForEach-Object { + $RequiredModule = $_ + # Import module from src folder. + $ModuleManifest = Join-Path $ModulesSrc $RequiredModule $CurrentApiVersion "$Module.$RequiredModule.psd1" + $LoadedModule = Import-Module $ModuleManifest -PassThru -ErrorAction SilentlyContinue + if ($null -ne $LoadedModule) { + # TODO: Handle pre release modules. + # $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version; Prerelease = $LoadedModule.Prerelease } + $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version } + } else { + Write-Warning "Module not found in $ModuleManifest." + } + } + + $ModuleManifestSettings.Path = "$MetaModuleModuleDir\$CurrentApiVersion\$Module.psd1" + $ModuleManifestSettings.RequiredModules = $RequiredGraphModules + + Write-Host -ForegroundColor Green "Creating '$Module' module manifest and nuspec..." + if ($ModulePreviewNumber -ge 0) { + # Prerelease is only supported in PowerShell 7 (preview) and above. + $ModuleManifestSettings["Prerelease"] = "preview$ModulePreviewNumber" + $NuspecOptions["version"] = $NuspecOptions["version"] + "-preview$ModulePreviewNumber" + } + $NuspecOptions["dependencies"] = $RequiredGraphModules + $NuspecOptions["id"] = $Module + + # Write-Output $NuspecOptions + New-ModuleManifest @ModuleManifestSettings + + $MetaModuleNuspec = Join-Path $MetaModuleModuleDir $CurrentApiVersion "$Module.nuspec" + if (-not (Test-Path $MetaModuleNuspec)) { + Copy-Item (Join-Path $PSScriptRoot "\Templates\$ModulePrefix.nuspec") -Destination $MetaModuleNuspec + } + + Set-NuSpecValuesFromManifest -NuSpecFilePath $MetaModuleNuspec -Manifest $NuspecOptions + + if ($Pack) { + Write-Host -ForegroundColor Green "Packing '$Module' module..." + & nuget pack $MetaModuleNuspec -OutputDirectory $RollUpModuleArtifactLocation -Prop Configuration=Release + } + + if ($LASTEXITCODE) { + Write-Error "Failed to pack $Module module." + } + + if ($Publish) { + # Publish roll-up module + & $PublishModulePS1 -Modules "Graph" -ModulePrefix $Module -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey + } + } +} + +Write-Host -ForegroundColor Green "-------------Done-------------" \ No newline at end of file diff --git a/tools/GenerateModules.ps1 b/tools/GenerateModules.ps1 index 641a96264e2..bc6fe77116b 100644 --- a/tools/GenerateModules.ps1 +++ b/tools/GenerateModules.ps1 @@ -4,7 +4,7 @@ Param( $ModulesToGenerate = @(), [ValidateSet("v1.0", "beta")] - $ApiVersionToGenerate = @("v1.0", "beta"), + $ApiVersion = @("v1.0", "beta"), [string] $RepositoryName = "PSGallery", [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), [int] $ModulePreviewNumber = -1, @@ -103,18 +103,17 @@ $ModulesToGenerate | ForEach-Object { Write-Error "Release notes not set on $ModuleFullName module. Please set 'release-notes' in $AutoRestModuleConfig." } - $ApiVersionToGenerate | ForEach-Object { - $ApiVersion = $_ - $OpenApiFile = Join-Path $OpenApiPath $ApiVersion "$Module.yml" + $ApiVersion | ForEach-Object { + $CurrentApiVersion = $_ + $OpenApiFile = Join-Path $OpenApiPath $CurrentApiVersion "$Module.yml" if (Test-Path $OpenApiFile) { - Write-Host -ForegroundColor Green "-------------[$ApiVersion]-------------" - $NamespacePrefix = ($ApiVersion -eq "beta" ? "$ModulePrefix.Beta" : $ModulePrefix) - # $ModuleName = ($ApiVersion -eq "beta" ? "Beta.$Module" : $Module) + Write-Host -ForegroundColor Green "-------------[$CurrentApiVersion]-------------" + $NamespacePrefix = ($CurrentApiVersion -eq "beta" ? "$ModulePrefix.Beta" : $ModulePrefix) $ModuleFullName = "$NamespacePrefix.$Module" - $ModuleProjectPath = Join-Path $ModulePath $ApiVersion + $ModuleProjectPath = Join-Path $ModulePath $CurrentApiVersion $AutoRestModuleConfig = Join-Path $ModuleProjectPath "\readme.md" - Copy-ModuleTemplate -Destination $AutoRestModuleConfig -TemplatePath (Join-Path $ScriptRoot "\Templates\readme$ApiVersion.md") -ModuleName $Module + Copy-ModuleTemplate -Destination $AutoRestModuleConfig -TemplatePath (Join-Path $ScriptRoot "\Templates\readme$CurrentApiVersion.md") -ModuleName $Module # Read specified module version from readme. $ModuleVersion = . $ReadModuleReadMePS1 -ReadMePath $AutoRestModuleConfig -FieldToRead "module-version" @@ -124,7 +123,7 @@ $ModulesToGenerate | ForEach-Object { } if ($SkipGeneration) { - Write-Warning "Skipping generation of '$ModuleFullName - $ApiVersion' module." + Write-Warning "Skipping generation of '$ModuleFullName - $CurrentApiVersion' module." } else { npx autorest --max-memory-size=$MaxMemorySize --module-version:$ModuleVersion --module-name:$ModuleFullName --service-name:$Module --input-file:$OpenApiFile $AutoRestModuleConfig From abdda20d5165f7ad7ebf49c28289b3d85d23e069 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 22 Jul 2022 16:37:05 -0700 Subject: [PATCH 25/30] Enable meta-module preview version. --- src/Graph/beta/Microsoft.Graph.Beta.nuspec | 2 +- src/Graph/beta/Microsoft.Graph.Beta.psd1 | 4 +- src/Graph/v1.0/Microsoft.Graph.nuspec | 2 +- src/Graph/v1.0/Microsoft.Graph.psd1 | 4 +- tools/GenerateMetaModule.ps1 | 195 +++++++++------------ 5 files changed, 91 insertions(+), 116 deletions(-) diff --git a/src/Graph/beta/Microsoft.Graph.Beta.nuspec b/src/Graph/beta/Microsoft.Graph.Beta.nuspec index ee2efca23dd..962e20219d8 100644 --- a/src/Graph/beta/Microsoft.Graph.Beta.nuspec +++ b/src/Graph/beta/Microsoft.Graph.Beta.nuspec @@ -2,7 +2,7 @@ Microsoft.Graph.Beta - 1.10.0 + 1.10.0-preview1 Microsoft Microsoft https://aka.ms/devservicesagreement diff --git a/src/Graph/beta/Microsoft.Graph.Beta.psd1 b/src/Graph/beta/Microsoft.Graph.Beta.psd1 index 2cdf717dd56..32748c7023f 100644 --- a/src/Graph/beta/Microsoft.Graph.Beta.psd1 +++ b/src/Graph/beta/Microsoft.Graph.Beta.psd1 @@ -18,7 +18,7 @@ ModuleVersion = '1.10.0' CompatiblePSEditions = 'Core', 'Desktop' # ID used to uniquely identify this module -GUID = '5fbd6f8c-b554-439a-a883-be5391e82229' +GUID = 'd87cd424-11ef-401a-8b1a-cf6ef9f82e54' # Author of this module Author = 'Microsoft' @@ -114,7 +114,7 @@ PrivateData = @{ ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.' # Prerelease string of this module - # Prerelease = '' + Prerelease = 'preview1' # Flag to indicate whether the module requires explicit user acceptance for install/update/save # RequireLicenseAcceptance = $false diff --git a/src/Graph/v1.0/Microsoft.Graph.nuspec b/src/Graph/v1.0/Microsoft.Graph.nuspec index 607a6a731c9..12a40f91522 100644 --- a/src/Graph/v1.0/Microsoft.Graph.nuspec +++ b/src/Graph/v1.0/Microsoft.Graph.nuspec @@ -2,7 +2,7 @@ Microsoft.Graph - 1.10.0 + 1.10.0-preview1 Microsoft Microsoft https://aka.ms/devservicesagreement diff --git a/src/Graph/v1.0/Microsoft.Graph.psd1 b/src/Graph/v1.0/Microsoft.Graph.psd1 index e51284d02b8..fcfbe002a6b 100644 --- a/src/Graph/v1.0/Microsoft.Graph.psd1 +++ b/src/Graph/v1.0/Microsoft.Graph.psd1 @@ -18,7 +18,7 @@ ModuleVersion = '1.10.0' CompatiblePSEditions = 'Core', 'Desktop' # ID used to uniquely identify this module -GUID = 'ed12d535-7fc8-43fe-a135-e04cf5e5daca' +GUID = 'bb5d95ba-9e29-40c0-a341-fc3a497185d0' # Author of this module Author = 'Microsoft' @@ -113,7 +113,7 @@ PrivateData = @{ ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.' # Prerelease string of this module - # Prerelease = '' + Prerelease = 'preview1' # Flag to indicate whether the module requires explicit user acceptance for install/update/save # RequireLicenseAcceptance = $false diff --git a/tools/GenerateMetaModule.ps1 b/tools/GenerateMetaModule.ps1 index 73b11790c0d..5c13208abf4 100644 --- a/tools/GenerateMetaModule.ps1 +++ b/tools/GenerateMetaModule.ps1 @@ -9,18 +9,12 @@ Param( [string] $RepositoryName = "PSGallery", [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), [string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc"), - [int] $ModulePreviewNumber = -1, [switch] $Pack, [switch] $Publish ) -enum VersionState { - Invalid - Valid - EqualToFeed - NotOnFeed -} $ErrorActionPreference = 'Stop' -$LASTEXITCODE = $null +$LASTEXITCODE = 0 + if ($PSEdition -ne 'Core') { Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.' } @@ -32,136 +26,117 @@ if (-not (Test-Path $ModuleMappingConfigPath)) { $ModulePrefix = "Microsoft.Graph" $NuspecHelperPS1 = Join-Path $PSScriptRoot ".\NuspecHelper.ps1" $PublishModulePS1 = Join-Path $PSScriptRoot ".\PublishModule.ps1" -Resolve -$ValidateUpdatedModuleVersionPS1 = Join-Path $PSScriptRoot ".\ValidateUpdatedModuleVersion.ps1" -Resolve $ModuleMetadataJson = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -Resolve $ModulesSrc = Join-Path $PSScriptRoot "..\src" $MetaModuleModuleDir = Join-Path $ModulesSrc "Graph" [HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable -[HashTable] $NuspecMetadata = Get-Content $ModuleMetadataJson | ConvertFrom-Json -AsHashTable -$NuspecMetadata.Remove("assemblyOriginatorKeyFile") +[HashTable] $ModuleMetadata = Get-Content $ModuleMetadataJson | ConvertFrom-Json -AsHashTable +$ModuleMetadata.Remove("assemblyOriginatorKeyFile") # Import scripts . $NuspecHelperPS1 -if ($null -eq $NuspecMetadata["version"]) { +if ($null -eq $ModuleMetadata["version"]) { # Module version not set in module manifest (psd1). Write-Error "Version number is not set on $ModulePrefix module. Please set 'version' in $ModuleMetadataJson." } - -# Validate module version with the one on PSGallery. -[VersionState]$VersionState = & $ValidateUpdatedModuleVersionPS1 -ModuleName $ModulePrefix -NextVersion $NuspecMetadata["version"] -if ($VersionState.Equals([VersionState]::Invalid)) { - Write-Warning "The specified version in $ModulePrefix module is either higher or lower than what's on $RepositoryName. Update 'version' in $ModuleMetadataJson." +$RollUpModuleArtifactLocation = "$ArtifactsLocation\graph" +if (-not (Test-Path $RollUpModuleArtifactLocation)) { + New-Item -Path $RollUpModuleArtifactLocation -Type Directory } -elseif ($VersionState.Equals([VersionState]::EqualToFeed)) { - Write-Warning "$ModulePrefix module skipped. Version has not changed and is equal to what's on $RepositoryName." +else { + Remove-Item -Path "$RollUpModuleArtifactLocation\*" -Recurse -Force } -elseif ($VersionState.Equals([VersionState]::Valid) -or $VersionState.Equals([VersionState]::NotOnFeed)) { - $NuspecMetadata["version"] = $VersionState.Equals([VersionState]::NotOnFeed) ? "0.1.1" : $NuspecMetadata["version"] - $RollUpModuleArtifactLocation = "$ArtifactsLocation\graph" - if (-not (Test-Path $RollUpModuleArtifactLocation)) { - New-Item -Path $RollUpModuleArtifactLocation -Type Directory - } - else { - Remove-Item -Path "$RollUpModuleArtifactLocation\*" -Recurse -Force - } +if (-not (Test-Path $MetaModuleModuleDir)) { + New-Item -Path $MetaModuleModuleDir -Type Directory +} - if (-not (Test-Path $MetaModuleModuleDir)) { - New-Item -Path $MetaModuleModuleDir -Type Directory - } - $AllowPreRelease = $true - if ($ModulePreviewNumber -eq -1) { - $AllowPreRelease = $false - } +[HashTable]$ModuleManifestSettings = @{ + CompatiblePSEditions = "Core", "Desktop" + PowerShellVersion = "5.1" + DotNetFrameworkVersion = "4.7.2" + ModuleVersion = $ModuleMetadata["version"] + Author = $ModuleMetadata["authors"] + CompanyName = $ModuleMetadata["owners"] + Copyright = $ModuleMetadata["copyright"] + Description = $ModuleMetadata["description"] + Tags = $ModuleMetadata["tags"] + LicenseUri = $ModuleMetadata["licenseUri"] + ProjectUri = $ModuleMetadata["projectUri"] + IconUri = $ModuleMetadata["iconUri"] + ReleaseNotes = $ModuleMetadata["releaseNotes"] + RequiredModules = @() + AliasesToExport = @() + CmdletsToExport = @() + FunctionsToExport = @() +} - [HashTable]$ModuleManifestSettings = @{ - CompatiblePSEditions = "Core", "Desktop" - PowerShellVersion = "5.1" - DotNetFrameworkVersion = "4.7.2" - ModuleVersion = $NuspecMetadata["version"] - Author = $NuspecMetadata["authors"] - CompanyName = $NuspecMetadata["owners"] - Copyright = $NuspecMetadata["copyright"] - Description = $NuspecMetadata["description"] - Tags = $NuspecMetadata["tags"] - LicenseUri = $NuspecMetadata["licenseUri"] - ProjectUri = $NuspecMetadata["projectUri"] - IconUri = $NuspecMetadata["iconUri"] - ReleaseNotes = $NuspecMetadata["releaseNotes"] - RequiredModules = @() - AliasesToExport = @() - CmdletsToExport = @() - FunctionsToExport = @() +# Import authentication module from src folder. +$AuthModuleManifest = Join-Path $ModulesSrc "Authentication" "Authentication" "artifacts" "Microsoft.Graph.Authentication.psd1" +$LoadedAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction SilentlyContinue + +$ApiVersion | ForEach-Object { + $CurrentApiVersion = $_ + $NuspecOptions = $ModuleMetadata.Clone() + $Module = ($CurrentApiVersion -eq "beta" ? "$ModulePrefix.Beta" : $ModulePrefix) + $RequiredGraphModules = @() + if ($null -ne $LoadedAuthModule) { + # TODO: Handle pre release dependency. + # LoadedAuthModule.Prerelease + $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; RequiredVersion = $LoadedAuthModule.Version } + } + else { + Write-Warning "Module not found in $AuthModuleManifest." } - # Import authentication module from src folder. - $AuthModuleManifest = Join-Path $ModulesSrc "Authentication" "Authentication" "artifacts" "Microsoft.Graph.Authentication.psd1" - $LoadedAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction SilentlyContinue - - $ApiVersion | ForEach-Object { - $CurrentApiVersion = $_ - $NuspecOptions = $NuspecMetadata.Clone() - $Module = ($CurrentApiVersion -eq "beta" ? "$ModulePrefix.Beta" : $ModulePrefix) - $RequiredGraphModules = @() - if ($null -ne $LoadedAuthModule) { - # TODO: Handle pre release modules. - # $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; RequiredVersion = $LoadedAuthModule.Version; Prerelease = $LoadedAuthModule.Prerelease } - $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; RequiredVersion = $LoadedAuthModule.Version } - } else { - Write-Warning "Module not found in $AuthModuleManifest." + $ModuleMapping.Keys | ForEach-Object { + $RequiredModule = $_ + # Import module from src folder. + $ModuleManifest = Join-Path $ModulesSrc $RequiredModule $CurrentApiVersion "$Module.$RequiredModule.psd1" + $LoadedModule = Import-Module $ModuleManifest -PassThru -ErrorAction SilentlyContinue + if ($null -ne $LoadedModule) { + # TODO: Handle pre release dependencies. + # $LoadedModule.Prerelease + $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version; } } - - $ModuleMapping.Keys | ForEach-Object { - $RequiredModule = $_ - # Import module from src folder. - $ModuleManifest = Join-Path $ModulesSrc $RequiredModule $CurrentApiVersion "$Module.$RequiredModule.psd1" - $LoadedModule = Import-Module $ModuleManifest -PassThru -ErrorAction SilentlyContinue - if ($null -ne $LoadedModule) { - # TODO: Handle pre release modules. - # $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version; Prerelease = $LoadedModule.Prerelease } - $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version } - } else { - Write-Warning "Module not found in $ModuleManifest." - } + else { + Write-Warning "Module not found in $ModuleManifest." } + } - $ModuleManifestSettings.Path = "$MetaModuleModuleDir\$CurrentApiVersion\$Module.psd1" - $ModuleManifestSettings.RequiredModules = $RequiredGraphModules - - Write-Host -ForegroundColor Green "Creating '$Module' module manifest and nuspec..." - if ($ModulePreviewNumber -ge 0) { - # Prerelease is only supported in PowerShell 7 (preview) and above. - $ModuleManifestSettings["Prerelease"] = "preview$ModulePreviewNumber" - $NuspecOptions["version"] = $NuspecOptions["version"] + "-preview$ModulePreviewNumber" - } - $NuspecOptions["dependencies"] = $RequiredGraphModules - $NuspecOptions["id"] = $Module + Write-Host -ForegroundColor Green "Creating '$Module' module manifest..." + $ModuleManifestSettings.Path = "$MetaModuleModuleDir\$CurrentApiVersion\$Module.psd1" + $ModuleManifestSettings.RequiredModules = $RequiredGraphModules + if ($NuspecOptions["prerelease"]) { + $ModuleManifestSettings.Prerelease = $NuspecOptions["prerelease"] + } + New-ModuleManifest @ModuleManifestSettings - # Write-Output $NuspecOptions - New-ModuleManifest @ModuleManifestSettings + Write-Host -ForegroundColor Green "Creating '$Module' module nuspec..." + $NuspecOptions["dependencies"] = $RequiredGraphModules + $NuspecOptions["id"] = $Module - $MetaModuleNuspec = Join-Path $MetaModuleModuleDir $CurrentApiVersion "$Module.nuspec" - if (-not (Test-Path $MetaModuleNuspec)) { - Copy-Item (Join-Path $PSScriptRoot "\Templates\$ModulePrefix.nuspec") -Destination $MetaModuleNuspec - } + $MetaModuleNuspec = Join-Path $MetaModuleModuleDir $CurrentApiVersion "$Module.nuspec" + if (-not (Test-Path $MetaModuleNuspec)) { + Copy-Item (Join-Path $PSScriptRoot "\Templates\$ModulePrefix.nuspec") -Destination $MetaModuleNuspec + } - Set-NuSpecValuesFromManifest -NuSpecFilePath $MetaModuleNuspec -Manifest $NuspecOptions + Set-NuSpecValuesFromManifest -NuSpecFilePath $MetaModuleNuspec -Manifest $NuspecOptions - if ($Pack) { - Write-Host -ForegroundColor Green "Packing '$Module' module..." - & nuget pack $MetaModuleNuspec -OutputDirectory $RollUpModuleArtifactLocation -Prop Configuration=Release - } + if ($Pack) { + Write-Host -ForegroundColor Green "Packing '$Module' module..." + & nuget pack $MetaModuleNuspec -OutputDirectory $RollUpModuleArtifactLocation -Prop Configuration=Release + } - if ($LASTEXITCODE) { - Write-Error "Failed to pack $Module module." - } + if ($LASTEXITCODE) { + Write-Error "Failed to pack $Module module." + } - if ($Publish) { - # Publish roll-up module - & $PublishModulePS1 -Modules "Graph" -ModulePrefix $Module -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey - } + if ($Publish) { + # Publish roll-up module + & $PublishModulePS1 -Modules "Graph" -ModulePrefix $Module -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey } } From 2271015737b3aa23a5671cb61d85fa06406e2df0 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 22 Jul 2022 16:37:35 -0700 Subject: [PATCH 26/30] Set meta-module preview version. --- config/ModuleMetadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/ModuleMetadata.json b/config/ModuleMetadata.json index ae7f6893025..bd5d3cbcd10 100644 --- a/config/ModuleMetadata.json +++ b/config/ModuleMetadata.json @@ -22,5 +22,6 @@ ], "releaseNotes": "See https://aka.ms/GraphPowerShell-Release.", "assemblyOriginatorKeyFile": "35MSSharedLib1024.snk", - "version": "1.10.0" + "version": "1.10.0", + "prerelease": "preview1" } From 125f21ecb8d5d5bd1d303315ec8dff12742d2fb1 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Fri, 22 Jul 2022 17:14:30 -0700 Subject: [PATCH 27/30] Enable auth module preview version. --- .../Microsoft.Graph.Authentication.csproj | 2 + .../Microsoft.Graph.Authentication.nuspec | 2 +- .../Microsoft.Graph.Authentication.psd1 | 9 +-- tools/BuildModule.ps1 | 39 +++++------ tools/CSProjHelper.ps1 | 11 +++- tools/GenerateAuthenticationModule.ps1 | 65 +++++-------------- tools/NuspecHelper.ps1 | 8 +++ 7 files changed, 61 insertions(+), 75 deletions(-) diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj index 815e228a062..499031ecb04 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj @@ -11,6 +11,8 @@ Microsoft.Graph.Authentication.nuspec © Microsoft Corporation. All rights reserved. + 1.10.0 + preview1 true diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec index 074369a0eb5..e5db6bad839 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec @@ -1,7 +1,7 @@ - 1.9.5 + 1.10.0-preview1 Microsoft.Graph.Authentication Microsoft Graph PowerShell authentication module Microsoft diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 index 855bb1d4e0b..77478868cdc 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 6/15/2022 +# Generated on: 7/22/2022 # @{ @@ -72,8 +72,9 @@ FormatsToProcess = 'Microsoft.Graph.Authentication.format.ps1xml' FunctionsToExport = 'Find-MgGraphCommand', 'Find-MgGraphPermission' # 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. -CmdletsToExport = 'Connect-MgGraph', 'Disconnect-MgGraph', 'Get-MgContext', 'Invoke-MgGraphRequest', - 'Add-MgEnvironment', 'Get-MgEnvironment', 'Remove-MgEnvironment', 'Set-MgEnvironment' +CmdletsToExport = 'Connect-MgGraph', 'Disconnect-MgGraph', 'Get-MgContext', + 'Invoke-MgGraphRequest', 'Add-MgEnvironment', 'Get-MgEnvironment', + 'Remove-MgEnvironment', 'Set-MgEnvironment' # Variables to export from this module # VariablesToExport = @() @@ -111,7 +112,7 @@ PrivateData = @{ ReleaseNotes = 'See https://aka.ms/GraphPowerShell-Release.' # Prerelease string of this module - # Prerelease = '' + Prerelease = 'preview1' # Flag to indicate whether the module requires explicit user acceptance for install/update/save # RequireLicenseAcceptance = $false diff --git a/tools/BuildModule.ps1 b/tools/BuildModule.ps1 index bfdf27bbc06..769beb94928 100644 --- a/tools/BuildModule.ps1 +++ b/tools/BuildModule.ps1 @@ -23,7 +23,7 @@ $BuildModulePS1 = Join-Path $ModuleSrc "/build-module.ps1" $ModuleCsProj = Join-Path $ModuleSrc "$ModuleFullName.csproj" $ModuleManifest = Join-Path $ModuleSrc "$ModuleFullName.psd1" $ModuleNuspec = Join-Path $ModuleSrc "$ModuleFullName.nuspec" -[HashTable] $NuspecMetadata = Get-Content (Join-Path $PSScriptRoot "..\config\ModuleMetadata.json") | ConvertFrom-Json -AsHashTable +[HashTable] $ModuleMetadata = Get-Content (Join-Path $PSScriptRoot "..\config\ModuleMetadata.json") | ConvertFrom-Json -AsHashTable # Import scripts . $NuspecHelperPS1 . $CSProjHelperPS1 @@ -32,12 +32,13 @@ if (-not (Test-Path -Path $BuildModulePS1)) { Write-Error "Build script file '$BuildModulePS1' not found for '$ModuleFullName' module." } +# TODO: Enable preview versions in CSproj. # Set delay sign to true. if ($EnableSigning) { - Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleVersion -AssemblyOriginatorKeyFile $NuspecMetadata["assemblyOriginatorKeyFile"] + Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleMetadata["version"] -PreRelease $ModuleMetadata["prerelease"] -AssemblyOriginatorKeyFile $ModuleMetadata["assemblyOriginatorKeyFile"] } else { - Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleVersion -Copyright $NuspecMetadata["copyright"] + Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleMetadata["version"] -PreRelease $ModuleMetadata["prerelease"] -Copyright $ModuleMetadata["copyright"] } # Build module @@ -50,29 +51,25 @@ if ($lastexitcode -ne 0) { [HashTable]$ModuleManifestSettings = @{ Path = $ModuleManifest - ModuleVersion = $ModuleVersion - IconUri = $NuspecMetadata["iconUri"] + ModuleVersion = $ModuleMetadata["version"] + IconUri = $ModuleMetadata["iconUri"] ReleaseNotes = $ReleaseNotes } -$FullVersionNumber = $ModuleVersion -if ($ModulePreviewNumber -ge 0) { - if ($RequiredModules.Count -gt 0) { - # Prerelease is only supported in PowerShell 7 (preview) and above. - $ModuleManifestSettings["RequiredModules"] = $RequiredModules - $ModuleManifestSettings["Prerelease"] = "preview$ModulePreviewNumber" - } - else { - $ModuleManifestSettings["Prerelease"] = "preview$ModulePreviewNumber" - } - $FullVersionNumber = "$ModuleVersion-preview$ModulePreviewNumber" +if ($ModuleMetadata["prerelease"]) { + $ModuleManifestSettings.Prerelease = $ModuleMetadata["prerelease"] } -else { - if ($RequiredModules.Count -gt 0) { - $ModuleManifestSettings["RequiredModules"] = $RequiredModules - } +if ($RequiredModules.Count -gt 0) { + $ModuleManifestSettings["RequiredModules"] = $RequiredModules +} + +# TODO: Refactor this line to use Set-NuSpecValuesFromManifest. Rename to ModuleVersion after refactor. +if ($ModuleMetadata["prerelease"]) { + $FullVersionNumber = "$($ModuleMetadata["version"])-$($ModuleMetadata["prerelease"])" +} else { + $FullVersionNumber = $ModuleMetadata["version"] } Write-Debug "Updating '$ModuleFullName' module manifest and nuspec..." Update-ModuleManifest @ModuleManifestSettings -Set-NuSpecValues -NuSpecFilePath $ModuleNuspec -VersionNumber $FullVersionNumber -Dependencies $RequiredModules -IconUrl $NuspecMetadata["iconUri"] -ReleaseNotes $ReleaseNotes +Set-NuSpecValues -NuSpecFilePath $ModuleNuspec -VersionNumber $FullVersionNumber -Dependencies $RequiredModules -IconUrl $ModuleMetadata["iconUri"] -ReleaseNotes $ReleaseNotes diff --git a/tools/CSProjHelper.ps1 b/tools/CSProjHelper.ps1 index 65150f373a8..c481fa4c3c0 100644 --- a/tools/CSProjHelper.ps1 +++ b/tools/CSProjHelper.ps1 @@ -4,6 +4,7 @@ function Set-CSProjValues( [parameter(Mandatory = $true)][string] $ModuleCsProj, [parameter(Mandatory = $true)][string] $ModuleVersion, + [parameter(Mandatory = $true)][string] $PreRelease, [string] $Copyright, [string] $AssemblyOriginatorKeyFile) { $NuspecHelperPS1 = Join-Path $PSScriptRoot "./NuspecHelper.ps1" @@ -28,8 +29,14 @@ function Set-CSProjValues( if (![string]::IsNullOrWhiteSpace($Copyright)) { Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "Copyright" -ElementValue $Copyright } - Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "Version" -ElementValue $ModuleVersion + + if ($PreRelease) { + Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "VersionPrefix" -ElementValue $ModuleVersion + Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "VersionSuffix" -ElementValue $PreRelease + } else { + Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "Version" -ElementValue $ModuleVersion + } $ModuleProjDoc.Save($ModuleCsProj) Write-Host "Updated the $ModuleCsProj." -} \ No newline at end of file +} diff --git a/tools/GenerateAuthenticationModule.ps1 b/tools/GenerateAuthenticationModule.ps1 index 884aaef3aa4..b54bfe9eb9b 100644 --- a/tools/GenerateAuthenticationModule.ps1 +++ b/tools/GenerateAuthenticationModule.ps1 @@ -11,17 +11,11 @@ Param( [switch] $EnableSigning, [switch] $BuildWhenEqual, [switch] $Test, - [switch] $Run, - [int] $ModulePreviewNumber = -1 + [switch] $Run ) -enum VersionState { - Invalid - Valid - EqualToFeed - NotOnFeed -} $ErrorActionPreference = 'Stop' -$LASTEXITCODE = $null +$LASTEXITCODE = 0 + if ($PSEdition -ne 'Core') { Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.' } @@ -30,16 +24,13 @@ $ModulePrefix = "Microsoft.Graph" $ModuleName = "Authentication" $ModuleFullName = "$ModulePrefix.$ModuleName" $AuthModuleManifest = "Microsoft.Graph.Authentication.psd1" -$SigningKeyFile = "35MSSharedLib1024.snk" $BuildModulePS1 = Join-Path $PSScriptRoot ".\BuildModule.ps1" -Resolve $PackModulePS1 = Join-Path $PSScriptRoot ".\PackModule.ps1" -Resolve $PublishModulePS1 = Join-Path $PSScriptRoot ".\PublishModule.ps1" -Resolve -$ValidateUpdatedModuleVersionPS1 = Join-Path $PSScriptRoot ".\ValidateUpdatedModuleVersion.ps1" -Resolve $AuthSrcPath = Join-Path $PSScriptRoot "..\src\Authentication\" $AuthModulePath = Join-Path $AuthSrcPath "Authentication" -Resolve $TestModulePS1 = Join-Path $PSScriptRoot ".\TestModule.ps1" -Resolve $RunModulePS1 = Join-Path $AuthModulePath ".\run-module.ps1" -Resolve -$AuthCoreCSProj = Join-Path $AuthSrcPath "$ModuleName.Core" "$ModuleFullName.Core.csproj" $CSProjHelperPS1 = Join-Path $PSScriptRoot "./CSProjHelper.ps1" # Import scripts @@ -51,45 +42,25 @@ if ($null -eq $ManifestContent.ModuleVersion) { # Module version not set in module manifest (psd1). Write-Error "Version number is not set on $ModuleFullName module. Please set 'ModuleVersion' in $AuthModulePath\$AuthModuleManifest." } -$AllowPreRelease = $true -if ($ModulePreviewNumber -eq -1) { - $AllowPreRelease = $false -} -# Validate module version with the one on PSGallery. -[VersionState]$VersionState = & $ValidateUpdatedModuleVersionPS1 -ModuleName "$ModuleFullName" -NextVersion $ManifestContent.ModuleVersion -PSRepository $RepositoryName -ModulePreviewNumber $ModulePreviewNumber -if ($VersionState.Equals([VersionState]::Invalid)) { - Write-Warning "The specified version in $ModuleFullName module is either higher or lower than what's on $RepositoryName. Update 'ModuleVersion' in $AuthModulePath$AuthModuleManifest." +$ModuleVersion = $ManifestContent.ModuleVersion +# Build and pack generated module. +if ($Build -or $Run) { + & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -ReleaseNotes $ManifestContent.PrivateData.PSData.ReleaseNotes -EnableSigning:$EnableSigning } -elseif ($VersionState.Equals([VersionState]::EqualToFeed) -and !$BuildWhenEqual) { - Write-Warning "$ModuleFullName module skipped. Version has not changed and is equal to what's on $RepositoryName." + +if ($Test) { + & $TestModulePS1 -ModulePath (Join-Path $AuthModulePath "artifacts" ) -ModuleName "$ModuleFullName" -ModuleTestsPath (Join-Path $AuthModulePath "test") } -elseif ($VersionState.Equals([VersionState]::Valid) -or $VersionState.Equals([VersionState]::NotOnFeed) -or $BuildWhenEqual) { - $ModuleVersion = $ManifestContent.ModuleVersion - # Build and pack generated module. - if ($Build -or $Run) { - if ($EnableSigning) { - Set-CSProjValues -ModuleCsProj $AuthCoreCSProj -ModuleVersion $ModuleVersion -AssemblyOriginatorKeyFile $SigningKeyFile - & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -ReleaseNotes $ManifestContent.PrivateData.PSData.ReleaseNotes -EnableSigning - } - else { - Set-CSProjValues -ModuleCsProj $AuthCoreCSProj -ModuleVersion $ModuleVersion - & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -ReleaseNotes $ManifestContent.PrivateData.PSData.ReleaseNotes - } - } - if ($Test) { - & $TestModulePS1 -ModulePath (Join-Path $AuthModulePath "artifacts" ) -ModuleName "$ModuleFullName" -ModuleTestsPath (Join-Path $AuthModulePath "test") - } - if ($Pack -or $Run) { - & $PackModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -Module $ModuleName -ArtifactsLocation $ArtifactsLocation - } +if ($Pack -or $Run) { + & $PackModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -Module $ModuleName -ArtifactsLocation $ArtifactsLocation +} - if ($Run) { - & $RunModulePS1 -ModuleName "$ModuleFullName" -ArtifactLocation $ArtifactsLocation - } +if ($Run) { + & $RunModulePS1 -ModuleName "$ModuleFullName" -ArtifactLocation $ArtifactsLocation +} - if ($Publish) { - & $PublishModulePS1 -Modules $ModuleName -ModulePrefix $ModulePrefix -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey - } +if ($Publish) { + & $PublishModulePS1 -Modules $ModuleName -ModulePrefix $ModulePrefix -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey } diff --git a/tools/NuspecHelper.ps1 b/tools/NuspecHelper.ps1 index 4b650166c9c..93654238dda 100644 --- a/tools/NuspecHelper.ps1 +++ b/tools/NuspecHelper.ps1 @@ -37,6 +37,14 @@ function Set-NuSpecValuesFromManifest( Set-Dependencies -XmlDocument $XmlDocument -MetadataElement $MetadataElement -Dependencies $Manifest["dependencies"] $Manifest.Remove("dependencies") + if ($Manifest["prerelease"]) { + Set-ElementValue -XmlDocument $XmlDocument -MetadataElement $MetadataElement -ElementName "version" -ElementValue "$($Manifest["version"])-$($Manifest["prerelease"])" + } else { + Set-ElementValue -XmlDocument $XmlDocument -MetadataElement $MetadataElement -ElementName "version" -ElementValue $Manifest["version"] + } + $Manifest.Remove("version") + $Manifest.Remove("prerelease") + Set-ElementValue -XmlDocument $XmlDocument -MetadataElement $MetadataElement -ElementName "projectUrl" -ElementValue $Manifest["projectUri"] $Manifest.Remove("projectUri") From 4e9db2dcfc754d27450eef572dccde5074ecc250 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 3 Aug 2022 12:35:25 -0700 Subject: [PATCH 28/30] Read module version from metamodule config. --- config/ModuleMetadata.json | 28 ++++++++---- tools/BuildModule.ps1 | 30 ++++++------- tools/GenerateAuthenticationModule.ps1 | 17 +++----- tools/GenerateMetaModule.ps1 | 36 +++++++--------- tools/GenerateModules.ps1 | 60 ++++++++------------------ tools/NuspecHelper.ps1 | 6 ++- tools/SetModuleVersion.ps1 | 30 +++++++++++++ 7 files changed, 107 insertions(+), 100 deletions(-) create mode 100644 tools/SetModuleVersion.ps1 diff --git a/config/ModuleMetadata.json b/config/ModuleMetadata.json index bd5d3cbcd10..e1e8dde3ecc 100644 --- a/config/ModuleMetadata.json +++ b/config/ModuleMetadata.json @@ -1,12 +1,14 @@ { + "assemblyOriginatorKeyFile": "35MSSharedLib1024.snk", "authors": "Microsoft", - "owners": "Microsoft", - "description": "Microsoft Graph PowerShell module", - "requireLicenseAcceptance": "true", "copyright": "© Microsoft Corporation. All rights reserved.", + "description": "Microsoft Graph PowerShell module", + "iconUri": "https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png", "licenseUri": "https://aka.ms/devservicesagreement", + "owners": "Microsoft", "projectUri": "https://github.com/microsoftgraph/msgraph-sdk-powershell", - "iconUri": "https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png", + "releaseNotes": "See https://aka.ms/GraphPowerShell-Release.", + "requireLicenseAcceptance": "true", "tags": [ "MicrosoftGraph", "Microsoft", @@ -20,8 +22,18 @@ "Intune", "AzureAutomationNotSupported" ], - "releaseNotes": "See https://aka.ms/GraphPowerShell-Release.", - "assemblyOriginatorKeyFile": "35MSSharedLib1024.snk", - "version": "1.10.0", - "prerelease": "preview1" + "versions": { + "authentication": { + "prerelease": "preview1", + "version": "1.11.0" + }, + "beta": { + "prerelease": "preview1", + "version": "1.11.0" + }, + "v1.0": { + "prerelease": "preview1", + "version": "1.11.0" + } + } } diff --git a/tools/BuildModule.ps1 b/tools/BuildModule.ps1 index 769beb94928..f35530980fa 100644 --- a/tools/BuildModule.ps1 +++ b/tools/BuildModule.ps1 @@ -4,9 +4,9 @@ Param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ModuleSrc, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ModuleFullName, - [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ModuleVersion, - [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string[]] $ReleaseNotes, - [int] $ModulePreviewNumber = -1, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][HashTable] $ModuleMetadata, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $Version, + [Parameter()] [ValidateNotNullOrEmpty()][string] $Prerelease, [hashtable[]] $RequiredModules, [switch] $EnableSigning, [switch] $ExcludeExampleTemplates, @@ -23,7 +23,6 @@ $BuildModulePS1 = Join-Path $ModuleSrc "/build-module.ps1" $ModuleCsProj = Join-Path $ModuleSrc "$ModuleFullName.csproj" $ModuleManifest = Join-Path $ModuleSrc "$ModuleFullName.psd1" $ModuleNuspec = Join-Path $ModuleSrc "$ModuleFullName.nuspec" -[HashTable] $ModuleMetadata = Get-Content (Join-Path $PSScriptRoot "..\config\ModuleMetadata.json") | ConvertFrom-Json -AsHashTable # Import scripts . $NuspecHelperPS1 . $CSProjHelperPS1 @@ -32,13 +31,12 @@ if (-not (Test-Path -Path $BuildModulePS1)) { Write-Error "Build script file '$BuildModulePS1' not found for '$ModuleFullName' module." } -# TODO: Enable preview versions in CSproj. # Set delay sign to true. if ($EnableSigning) { - Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleMetadata["version"] -PreRelease $ModuleMetadata["prerelease"] -AssemblyOriginatorKeyFile $ModuleMetadata["assemblyOriginatorKeyFile"] + Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $Version -PreRelease $Prerelease -AssemblyOriginatorKeyFile $ModuleMetadata["assemblyOriginatorKeyFile"] } else { - Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleMetadata["version"] -PreRelease $ModuleMetadata["prerelease"] -Copyright $ModuleMetadata["copyright"] + Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $Version -PreRelease $Prerelease -Copyright $ModuleMetadata["copyright"] } # Build module @@ -51,23 +49,21 @@ if ($lastexitcode -ne 0) { [HashTable]$ModuleManifestSettings = @{ Path = $ModuleManifest - ModuleVersion = $ModuleMetadata["version"] + ModuleVersion = $Version IconUri = $ModuleMetadata["iconUri"] - ReleaseNotes = $ReleaseNotes + ReleaseNotes = $ModuleMetadata["releaseNotes"] } -if ($ModuleMetadata["prerelease"]) { - $ModuleManifestSettings.Prerelease = $ModuleMetadata["prerelease"] -} if ($RequiredModules.Count -gt 0) { $ModuleManifestSettings["RequiredModules"] = $RequiredModules } -# TODO: Refactor this line to use Set-NuSpecValuesFromManifest. Rename to ModuleVersion after refactor. -if ($ModuleMetadata["prerelease"]) { - $FullVersionNumber = "$($ModuleMetadata["version"])-$($ModuleMetadata["prerelease"])" -} else { - $FullVersionNumber = $ModuleMetadata["version"] +if ($Prerelease) { + $ModuleManifestSettings.Prerelease = $Prerelease + $FullVersionNumber = "$Version-$Prerelease" +} +else { + $FullVersionNumber = $Version } Write-Debug "Updating '$ModuleFullName' module manifest and nuspec..." diff --git a/tools/GenerateAuthenticationModule.ps1 b/tools/GenerateAuthenticationModule.ps1 index b54bfe9eb9b..7fc3f9f7b34 100644 --- a/tools/GenerateAuthenticationModule.ps1 +++ b/tools/GenerateAuthenticationModule.ps1 @@ -23,7 +23,6 @@ if ($PSEdition -ne 'Core') { $ModulePrefix = "Microsoft.Graph" $ModuleName = "Authentication" $ModuleFullName = "$ModulePrefix.$ModuleName" -$AuthModuleManifest = "Microsoft.Graph.Authentication.psd1" $BuildModulePS1 = Join-Path $PSScriptRoot ".\BuildModule.ps1" -Resolve $PackModulePS1 = Join-Path $PSScriptRoot ".\PackModule.ps1" -Resolve $PublishModulePS1 = Join-Path $PSScriptRoot ".\PublishModule.ps1" -Resolve @@ -31,22 +30,16 @@ $AuthSrcPath = Join-Path $PSScriptRoot "..\src\Authentication\" $AuthModulePath = Join-Path $AuthSrcPath "Authentication" -Resolve $TestModulePS1 = Join-Path $PSScriptRoot ".\TestModule.ps1" -Resolve $RunModulePS1 = Join-Path $AuthModulePath ".\run-module.ps1" -Resolve -$CSProjHelperPS1 = Join-Path $PSScriptRoot "./CSProjHelper.ps1" +$ModuleMetadataPath = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" +[HashTable] $ModuleMetadata = Get-Content $ModuleMetadataPath | ConvertFrom-Json -AsHashTable -# Import scripts -. $CSProjHelperPS1 - -# Read ModuleVersion set on local auth module. -$ManifestContent = Import-LocalizedData -BaseDirectory $AuthModulePath -FileName $AuthModuleManifest -if ($null -eq $ManifestContent.ModuleVersion) { - # Module version not set in module manifest (psd1). - Write-Error "Version number is not set on $ModuleFullName module. Please set 'ModuleVersion' in $AuthModulePath\$AuthModuleManifest." +if ($null -eq $ModuleMetadata.versions.authentication.version) { + Write-Error "Version number is not set for $ModuleFullName module. Please set authentication version in $ModuleMetadataPath." } -$ModuleVersion = $ManifestContent.ModuleVersion # Build and pack generated module. if ($Build -or $Run) { - & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -ReleaseNotes $ManifestContent.PrivateData.PSData.ReleaseNotes -EnableSigning:$EnableSigning + & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -EnableSigning:$EnableSigning -Version $ModuleMetadata.versions.authentication.version -Prerelease $ModuleMetadata.versions.authentication.prerelease -ModuleMetadata $ModuleMetadata.Clone() } if ($Test) { diff --git a/tools/GenerateMetaModule.ps1 b/tools/GenerateMetaModule.ps1 index 5c13208abf4..1be5e32a846 100644 --- a/tools/GenerateMetaModule.ps1 +++ b/tools/GenerateMetaModule.ps1 @@ -8,7 +8,6 @@ Param( [string] $RepositoryApiKey, [string] $RepositoryName = "PSGallery", [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), - [string] $ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc"), [switch] $Pack, [switch] $Publish ) @@ -19,28 +18,24 @@ if ($PSEdition -ne 'Core') { Write-Error 'This script requires PowerShell Core to execute. [Note] Generated cmdlets will work in both PowerShell Core or Windows PowerShell.' } -if (-not (Test-Path $ModuleMappingConfigPath)) { - Write-Error "Module mapping file not be found: $ModuleMappingConfigPath." +$ModuleMappingPath = Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc" +if (-not (Test-Path $ModuleMappingPath)) { + Write-Error "Module mapping file not be found: $ModuleMappingPath." } $ModulePrefix = "Microsoft.Graph" $NuspecHelperPS1 = Join-Path $PSScriptRoot ".\NuspecHelper.ps1" $PublishModulePS1 = Join-Path $PSScriptRoot ".\PublishModule.ps1" -Resolve -$ModuleMetadataJson = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -Resolve +$ModuleMetadataPath = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -Resolve $ModulesSrc = Join-Path $PSScriptRoot "..\src" $MetaModuleModuleDir = Join-Path $ModulesSrc "Graph" -[HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable -[HashTable] $ModuleMetadata = Get-Content $ModuleMetadataJson | ConvertFrom-Json -AsHashTable +[HashTable] $ModuleMapping = Get-Content $ModuleMappingPath | ConvertFrom-Json -AsHashTable +[HashTable] $ModuleMetadata = Get-Content $ModuleMetadataPath | ConvertFrom-Json -AsHashTable $ModuleMetadata.Remove("assemblyOriginatorKeyFile") # Import scripts . $NuspecHelperPS1 -if ($null -eq $ModuleMetadata["version"]) { - # Module version not set in module manifest (psd1). - Write-Error "Version number is not set on $ModulePrefix module. Please set 'version' in $ModuleMetadataJson." -} - $RollUpModuleArtifactLocation = "$ArtifactsLocation\graph" if (-not (Test-Path $RollUpModuleArtifactLocation)) { New-Item -Path $RollUpModuleArtifactLocation -Type Directory @@ -57,7 +52,6 @@ if (-not (Test-Path $MetaModuleModuleDir)) { CompatiblePSEditions = "Core", "Desktop" PowerShellVersion = "5.1" DotNetFrameworkVersion = "4.7.2" - ModuleVersion = $ModuleMetadata["version"] Author = $ModuleMetadata["authors"] CompanyName = $ModuleMetadata["owners"] Copyright = $ModuleMetadata["copyright"] @@ -80,12 +74,13 @@ $LoadedAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction Sil $ApiVersion | ForEach-Object { $CurrentApiVersion = $_ $NuspecOptions = $ModuleMetadata.Clone() + $NuspecOptions.version = $ModuleMetadata.versions[$CurrentApiVersion].version + $NuspecOptions.prerelease = $ModuleMetadata.versions[$CurrentApiVersion].prerelease + $NuspecOptions.Remove("versions") $Module = ($CurrentApiVersion -eq "beta" ? "$ModulePrefix.Beta" : $ModulePrefix) $RequiredGraphModules = @() if ($null -ne $LoadedAuthModule) { - # TODO: Handle pre release dependency. - # LoadedAuthModule.Prerelease - $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; RequiredVersion = $LoadedAuthModule.Version } + $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; ModuleVersion = $LoadedAuthModule.Version } } else { Write-Warning "Module not found in $AuthModuleManifest." @@ -93,12 +88,9 @@ $ApiVersion | ForEach-Object { $ModuleMapping.Keys | ForEach-Object { $RequiredModule = $_ - # Import module from src folder. $ModuleManifest = Join-Path $ModulesSrc $RequiredModule $CurrentApiVersion "$Module.$RequiredModule.psd1" $LoadedModule = Import-Module $ModuleManifest -PassThru -ErrorAction SilentlyContinue if ($null -ne $LoadedModule) { - # TODO: Handle pre release dependencies. - # $LoadedModule.Prerelease $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version; } } else { @@ -107,10 +99,14 @@ $ApiVersion | ForEach-Object { } Write-Host -ForegroundColor Green "Creating '$Module' module manifest..." + if ($null -eq $NuspecOptions.version) { + Write-Error "Version number is not set for $ModulePrefix module. Please set 'version' in $ModuleMetadataPath." + } + $ModuleManifestSettings.ModuleVersion = $NuspecOptions.version $ModuleManifestSettings.Path = "$MetaModuleModuleDir\$CurrentApiVersion\$Module.psd1" $ModuleManifestSettings.RequiredModules = $RequiredGraphModules - if ($NuspecOptions["prerelease"]) { - $ModuleManifestSettings.Prerelease = $NuspecOptions["prerelease"] + if ($NuspecOptions.prerelease) { + $ModuleManifestSettings.Prerelease = $NuspecOptions.prerelease } New-ModuleManifest @ModuleManifestSettings diff --git a/tools/GenerateModules.ps1 b/tools/GenerateModules.ps1 index bc6fe77116b..43e2d21accc 100644 --- a/tools/GenerateModules.ps1 +++ b/tools/GenerateModules.ps1 @@ -7,7 +7,6 @@ Param( $ApiVersion = @("v1.0", "beta"), [string] $RepositoryName = "PSGallery", [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), - [int] $ModulePreviewNumber = -1, [switch] $SkipGeneration = $false, [switch] $Build, [switch] $Test, @@ -43,49 +42,39 @@ if (!(Get-Module -Name powershell-yaml -ListAvailable)) { $ENV:NODE_OPTIONS = "--max-old-space-size=$MaxMemorySize" $ModulePrefix = "Microsoft.Graph" $ScriptRoot = $PSScriptRoot -$ModulesOutputPath = Join-Path $ScriptRoot "..\src\" +$ModulesSrc = Join-Path $ScriptRoot "..\src\" $OpenApiPath = Join-Path $ScriptRoot "..\openApiDocs" $TemplatePath = Join-Path $ScriptRoot "\Templates\" -$ModuleMappingConfigPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc") +$ModuleMappingPath = (Join-Path $PSScriptRoot "..\config\ModulesMapping.jsonc") +$ModuleMetadataPath = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" +[HashTable] $ModuleMetadata = Get-Content $ModuleMetadataPath | ConvertFrom-Json -AsHashTable # PS Scripts $ManageGeneratedModulePS1 = Join-Path $ScriptRoot ".\ManageGeneratedModule.ps1" -Resolve $BuildModulePS1 = Join-Path $ScriptRoot ".\BuildModule.ps1" -Resolve $TestModulePS1 = Join-Path $ScriptRoot ".\TestModule.ps1" -Resolve $PackModulePS1 = Join-Path $ScriptRoot ".\PackModule.ps1" -Resolve -$ReadModuleReadMePS1 = Join-Path $ScriptRoot ".\ReadModuleReadMe.ps1" -Resolve $CleanUpPsm1 = Join-Path $ScriptRoot "\PostGeneration\CleanUpPsm1.ps1" -Resolve . (Join-Path $ScriptRoot "\Utilities\FileUtils.ps1") if (-not (Test-Path $ArtifactsLocation)) { New-Item -Path $ArtifactsLocation -Type Directory | Out-Null } -if (-not (Test-Path $ModuleMappingConfigPath)) { - Write-Error "Module mapping file not be found: $ModuleMappingConfigPath." +if (-not (Test-Path $ModuleMappingPath)) { + Write-Error "Module mapping file not be found: $ModuleMappingPath." } -$AllowPreRelease = $true -if ($ModulePreviewNumber -eq -1) { - $AllowPreRelease = $false -} $RequiredGraphModules = @() -# 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. -$ExistingAuthModule = Find-Module "Microsoft.Graph.Authentication" -Repository $RepositoryName -AllowPrerelease:$AllowPreRelease -Write-Debug "Auth Module: $($ExistingAuthModule.Name), $($ExistingAuthModule.Version)" -if (!(Get-Module -Name $ExistingAuthModule.Name -ListAvailable)) { - Install-Module $ExistingAuthModule.Name -Repository $RepositoryName -Force -AllowClobber -AllowPrerelease:$AllowPreRelease -} -if ($ExistingAuthModule.Version -like '*preview*' ) { - $version = $ExistingAuthModule.Version.Remove($ExistingAuthModule.Version.IndexOf('-')) - Write-Warning "Required Version: $ModulePrefix.$RequiredModule Version: $version" - $RequiredGraphModules += @{ ModuleName = $ExistingAuthModule.Name ; ModuleVersion = $version } +$AuthModuleManifest = Join-Path $ModulesSrc "Authentication" "Authentication" "artifacts" "Microsoft.Graph.Authentication.psd1" +$LoadedAuthModule = Import-Module $AuthModuleManifest -PassThru -ErrorAction SilentlyContinue +if ($null -ne $LoadedAuthModule) { + $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; ModuleVersion = $LoadedAuthModule.Version } } else { - $RequiredGraphModules += @{ ModuleName = $ExistingAuthModule.Name ; ModuleVersion = $ExistingAuthModule.Version } + Write-Warning "Module not found in $AuthModuleManifest." } if ($ModulesToGenerate.Count -eq 0) { - [HashTable] $ModuleMapping = Get-Content $ModuleMappingConfigPath | ConvertFrom-Json -AsHashTable + [HashTable] $ModuleMapping = Get-Content $ModuleMappingPath | ConvertFrom-Json -AsHashTable $ModulesToGenerate = $ModuleMapping.Keys } @@ -93,16 +82,10 @@ $Stopwatch = [system.diagnostics.stopwatch]::StartNew() $ModulesToGenerate | ForEach-Object { $Module = $_ Write-Host -ForegroundColor Green "-------------'$Module'-------------" - $ModulePath = Join-Path $ModulesOutputPath $Module + $ModulePath = Join-Path $ModulesSrc $Module $ModuleConfig = Join-Path $ModulePath "\$Module.md" Copy-ModuleTemplate -Destination $ModuleConfig -TemplatePath (Join-Path $TemplatePath "module.md") -ModuleName $Module - $ModuleReleaseNotes = & $ReadModuleReadMePS1 -ReadMePath $ModuleConfig -FieldToRead "release-notes" - if ($ModuleReleaseNotes -eq $null) { - # Release notes not set in readme.md. - Write-Error "Release notes not set on $ModuleFullName module. Please set 'release-notes' in $AutoRestModuleConfig." - } - $ApiVersion | ForEach-Object { $CurrentApiVersion = $_ $OpenApiFile = Join-Path $OpenApiPath $CurrentApiVersion "$Module.yml" @@ -115,18 +98,16 @@ $ModulesToGenerate | ForEach-Object { $AutoRestModuleConfig = Join-Path $ModuleProjectPath "\readme.md" Copy-ModuleTemplate -Destination $AutoRestModuleConfig -TemplatePath (Join-Path $ScriptRoot "\Templates\readme$CurrentApiVersion.md") -ModuleName $Module - # Read specified module version from readme. - $ModuleVersion = . $ReadModuleReadMePS1 -ReadMePath $AutoRestModuleConfig -FieldToRead "module-version" - if ($null -eq $ModuleVersion) { - # Module version not set in readme.md. - Write-Error "Version number is not set on $ModuleFullName module. Please set 'module-version' in $AutoRestModuleConfig." + if ($null -eq $ModuleMetadata.versions[$CurrentApiVersion].version) { + Write-Error "Version number is not set for $ModuleFullName module. Please set 'version' in $ModuleMetadataPath." } if ($SkipGeneration) { Write-Warning "Skipping generation of '$ModuleFullName - $CurrentApiVersion' module." } else { - npx autorest --max-memory-size=$MaxMemorySize --module-version:$ModuleVersion --module-name:$ModuleFullName --service-name:$Module --input-file:$OpenApiFile $AutoRestModuleConfig + $FullModuleVersion = "$($ModuleMetadata.versions[$CurrentApiVersion].version)-$($ModuleMetadata.versions[$CurrentApiVersion].prerelease)" + npx autorest --max-memory-size=$MaxMemorySize --module-version:$FullModuleVersion --module-name:$ModuleFullName --service-name:$Module --input-file:$OpenApiFile $AutoRestModuleConfig if ($LastExitCode -ne 0) { Write-Host -ForegroundColor Red "AutoREST failed to generate '$ModuleFullName' module." exit $LastExitCode @@ -140,12 +121,7 @@ $ModulesToGenerate | ForEach-Object { if ($Build) { # Build generated module. - if ($EnableSigning) { - & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $ModuleProjectPath -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $RequiredGraphModules -ReleaseNotes $ModuleReleaseNotes -EnableSigning -ExcludeExampleTemplates:$ExcludeExampleTemplates -ExcludeNotesSection:$ExcludeNotesSection - } - else { - & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $ModuleProjectPath -ModuleVersion $ModuleVersion -ModulePreviewNumber $ModulePreviewNumber -RequiredModules $RequiredGraphModules -ReleaseNotes $ModuleReleaseNotes -ExcludeExampleTemplates:$ExcludeExampleTemplates -ExcludeNotesSection:$ExcludeNotesSection - } + & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $ModuleProjectPath -RequiredModules $RequiredGraphModules -EnableSigning:$EnableSigning -ExcludeExampleTemplates:$ExcludeExampleTemplates -ExcludeNotesSection:$ExcludeNotesSection -Version $ModuleMetadata.versions[$CurrentApiVersion].version -Prerelease $ModuleMetadata.versions[$CurrentApiVersion].prerelease -ModuleMetadata $ModuleMetadata.Clone() & $CleanUpPsm1 -ModuleProjectPath $ModuleProjectPath -FullyQualifiedModuleName $ModuleFullName if ($LastExitCode -ne 0) { Write-Host -ForegroundColor Red "Failed to build '$ModuleFullName' module." diff --git a/tools/NuspecHelper.ps1 b/tools/NuspecHelper.ps1 index 93654238dda..ebc53cca3be 100644 --- a/tools/NuspecHelper.ps1 +++ b/tools/NuspecHelper.ps1 @@ -88,7 +88,11 @@ function Set-Dependencies( foreach($Dependency in $Dependencies){ $NewDependencyElement = $XmlDocument.CreateElement("dependency", $XmlDocument.DocumentElement.NamespaceURI) $NewDependencyElement.SetAttribute("id", $Dependency.ModuleName) - $NewDependencyElement.SetAttribute("version", $Dependency.ModuleVersion ?? $Dependency.RequiredVersion) + if ($Dependency.ModuleVersion) { + $NewDependencyElement.SetAttribute("version", $Dependency.ModuleVersion) + } else { + $NewDependencyElement.SetAttribute("version", "[$($Dependency.RequiredVersion)]") + } $MetadataElement["dependencies"].AppendChild($NewDependencyElement) | Out-Null } diff --git a/tools/SetModuleVersion.ps1 b/tools/SetModuleVersion.ps1 new file mode 100644 index 00000000000..03706a18a6e --- /dev/null +++ b/tools/SetModuleVersion.ps1 @@ -0,0 +1,30 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. +[CmdletBinding()] +Param( + [string] $Version, + [string] $Prerelease, + [switch] $SetAuthModule, + [switch] $SetBetaModule, + [switch] $SetV1Module +) +$ModuleMetadataPath = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" +# $ModuleMetadata = [ordered]@{} +$ModuleMetadata = Get-Content $ModuleMetadataPath | ConvertFrom-Json + +if ($SetAuthModule) { + $ModuleMetadata.versions.authentication.version = $Version + $ModuleMetadata.versions.authentication.prerelease = $Prerelease +} + +if ($SetBetaModule) { + $ModuleMetadata.versions.beta.version = $Version + $ModuleMetadata.versions.beta.prerelease = $Prerelease +} + +if ($SetV1Module) { + $ModuleMetadata.versions.'v1.0'.version = $Version + $ModuleMetadata.versions.'v1.0'.prerelease = $Prerelease +} + +$ModuleMetadata | ConvertTo-Json -Depth 5 | Out-File $ModuleMetadataPath -Encoding utf8 \ No newline at end of file From 7f860371f8aeec907bb9dfa81cbb0038abdc60f0 Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Wed, 3 Aug 2022 15:54:27 -0700 Subject: [PATCH 29/30] Generate prerelease workload modules. --- .../Microsoft.Graph.Authentication.Core.csproj | 3 ++- .../Microsoft.Graph.Authentication.csproj | 3 +-- .../Microsoft.Graph.Authentication.nuspec | 2 +- .../Microsoft.Graph.Authentication.psd1 | 4 ++-- src/Graph/beta/Microsoft.Graph.Beta.nuspec | 8 ++++---- src/Graph/beta/Microsoft.Graph.Beta.psd1 | 12 ++++++------ src/Graph/v1.0/Microsoft.Graph.nuspec | 6 +++--- src/Graph/v1.0/Microsoft.Graph.psd1 | 10 +++++----- tools/BuildModule.ps1 | 2 +- tools/CSProjHelper.ps1 | 5 ++++- tools/GenerateAuthenticationModule.ps1 | 11 +++++++++++ tools/GenerateModules.ps1 | 6 +++++- tools/ManageGeneratedModule.ps1 | 2 +- tools/NuspecHelper.ps1 | 12 +++++++++++- 14 files changed, 57 insertions(+), 29 deletions(-) diff --git a/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj b/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj index 3cb305ccd80..200e6231d35 100644 --- a/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj +++ b/src/Authentication/Authentication.Core/Microsoft.Graph.Authentication.Core.csproj @@ -3,7 +3,8 @@ netstandard2.0;net6.0;net472 Microsoft.Graph.PowerShell.Authentication.Core - 1.10.0 + 1.11.0 + preview1 true diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj index 499031ecb04..bc164122774 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.csproj @@ -1,6 +1,5 @@ - 1.10.0 7.1 netstandard2.0 Library @@ -11,7 +10,7 @@ Microsoft.Graph.Authentication.nuspec © Microsoft Corporation. All rights reserved. - 1.10.0 + 1.11.0 preview1 diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec index e5db6bad839..4888f72e24e 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec @@ -1,7 +1,7 @@ - 1.10.0-preview1 + 1.11.0-preview1 Microsoft.Graph.Authentication Microsoft Graph PowerShell authentication module Microsoft diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 index 77478868cdc..5884d883720 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 7/22/2022 +# Generated on: 8/3/2022 # @{ @@ -12,7 +12,7 @@ RootModule = './Microsoft.Graph.Authentication.psm1' # Version number of this module. -ModuleVersion = '1.10.0' +ModuleVersion = '1.11.0' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' diff --git a/src/Graph/beta/Microsoft.Graph.Beta.nuspec b/src/Graph/beta/Microsoft.Graph.Beta.nuspec index 962e20219d8..f78de3b6357 100644 --- a/src/Graph/beta/Microsoft.Graph.Beta.nuspec +++ b/src/Graph/beta/Microsoft.Graph.Beta.nuspec @@ -2,7 +2,7 @@ Microsoft.Graph.Beta - 1.10.0-preview1 + 1.11.0-preview1 Microsoft Microsoft https://aka.ms/devservicesagreement @@ -13,9 +13,9 @@ © Microsoft Corporation. All rights reserved. MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported - - - + + + See https://aka.ms/GraphPowerShell-Release. diff --git a/src/Graph/beta/Microsoft.Graph.Beta.psd1 b/src/Graph/beta/Microsoft.Graph.Beta.psd1 index 32748c7023f..fe8aba66a0d 100644 --- a/src/Graph/beta/Microsoft.Graph.Beta.psd1 +++ b/src/Graph/beta/Microsoft.Graph.Beta.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 7/22/2022 +# Generated on: 8/3/2022 # @{ @@ -12,13 +12,13 @@ # RootModule = '' # Version number of this module. -ModuleVersion = '1.10.0' +ModuleVersion = '1.11.0' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' # ID used to uniquely identify this module -GUID = 'd87cd424-11ef-401a-8b1a-cf6ef9f82e54' +GUID = '27260379-8df6-41d8-a3ca-067cb8f3ae5d' # Author of this module Author = 'Microsoft' @@ -51,9 +51,9 @@ DotNetFrameworkVersion = '4.7.2' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; RequiredVersion = '1.10.0'; }, - @{ModuleName = 'Microsoft.Graph.Beta.WindowsUpdates'; RequiredVersion = '1.9.6'; }, - @{ModuleName = 'Microsoft.Graph.Beta.Search'; RequiredVersion = '1.9.6'; }) +RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; ModuleVersion = '1.11.0'; }, + @{ModuleName = 'Microsoft.Graph.Beta.Search'; RequiredVersion = '1.11.0'; }, + @{ModuleName = 'Microsoft.Graph.Beta.WindowsUpdates'; RequiredVersion = '1.11.0'; }) # Assemblies that must be loaded prior to importing this module # RequiredAssemblies = @() diff --git a/src/Graph/v1.0/Microsoft.Graph.nuspec b/src/Graph/v1.0/Microsoft.Graph.nuspec index 12a40f91522..7ee9c766b7f 100644 --- a/src/Graph/v1.0/Microsoft.Graph.nuspec +++ b/src/Graph/v1.0/Microsoft.Graph.nuspec @@ -2,7 +2,7 @@ Microsoft.Graph - 1.10.0-preview1 + 1.11.0-preview1 Microsoft Microsoft https://aka.ms/devservicesagreement @@ -13,8 +13,8 @@ © Microsoft Corporation. All rights reserved. MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported - - + + See https://aka.ms/GraphPowerShell-Release. diff --git a/src/Graph/v1.0/Microsoft.Graph.psd1 b/src/Graph/v1.0/Microsoft.Graph.psd1 index fcfbe002a6b..e74e3a2ea2e 100644 --- a/src/Graph/v1.0/Microsoft.Graph.psd1 +++ b/src/Graph/v1.0/Microsoft.Graph.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 7/22/2022 +# Generated on: 8/3/2022 # @{ @@ -12,13 +12,13 @@ # RootModule = '' # Version number of this module. -ModuleVersion = '1.10.0' +ModuleVersion = '1.11.0' # Supported PSEditions CompatiblePSEditions = 'Core', 'Desktop' # ID used to uniquely identify this module -GUID = 'bb5d95ba-9e29-40c0-a341-fc3a497185d0' +GUID = 'e32ebb56-a940-4829-8105-1459079eaae5' # Author of this module Author = 'Microsoft' @@ -51,8 +51,8 @@ DotNetFrameworkVersion = '4.7.2' # ProcessorArchitecture = '' # Modules that must be imported into the global environment prior to importing this module -RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; RequiredVersion = '1.10.0'; }, - @{ModuleName = 'Microsoft.Graph.Search'; RequiredVersion = '1.9.6'; }) +RequiredModules = @(@{ModuleName = 'Microsoft.Graph.Authentication'; ModuleVersion = '1.11.0'; }, + @{ModuleName = 'Microsoft.Graph.Search'; RequiredVersion = '1.11.0'; }) # Assemblies that must be loaded prior to importing this module # RequiredAssemblies = @() diff --git a/tools/BuildModule.ps1 b/tools/BuildModule.ps1 index f35530980fa..a5a9011f0c7 100644 --- a/tools/BuildModule.ps1 +++ b/tools/BuildModule.ps1 @@ -6,7 +6,7 @@ Param( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $ModuleFullName, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][HashTable] $ModuleMetadata, [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()][string] $Version, - [Parameter()] [ValidateNotNullOrEmpty()][string] $Prerelease, + [string] $Prerelease, [hashtable[]] $RequiredModules, [switch] $EnableSigning, [switch] $ExcludeExampleTemplates, diff --git a/tools/CSProjHelper.ps1 b/tools/CSProjHelper.ps1 index c481fa4c3c0..f2bb6c955f6 100644 --- a/tools/CSProjHelper.ps1 +++ b/tools/CSProjHelper.ps1 @@ -4,7 +4,7 @@ function Set-CSProjValues( [parameter(Mandatory = $true)][string] $ModuleCsProj, [parameter(Mandatory = $true)][string] $ModuleVersion, - [parameter(Mandatory = $true)][string] $PreRelease, + [string] $PreRelease, [string] $Copyright, [string] $AssemblyOriginatorKeyFile) { $NuspecHelperPS1 = Join-Path $PSScriptRoot "./NuspecHelper.ps1" @@ -33,8 +33,11 @@ function Set-CSProjValues( if ($PreRelease) { Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "VersionPrefix" -ElementValue $ModuleVersion Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "VersionSuffix" -ElementValue $PreRelease + Remove-Element -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "Version" } else { Set-ElementValue -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "Version" -ElementValue $ModuleVersion + Remove-Element -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "VersionSuffix" + Remove-Element -XmlDocument $ModuleProjDoc -MetadataElement $ModuleProjElement -ElementName "VersionPrefix" } $ModuleProjDoc.Save($ModuleCsProj) diff --git a/tools/GenerateAuthenticationModule.ps1 b/tools/GenerateAuthenticationModule.ps1 index 7fc3f9f7b34..9ee1d291e77 100644 --- a/tools/GenerateAuthenticationModule.ps1 +++ b/tools/GenerateAuthenticationModule.ps1 @@ -30,15 +30,26 @@ $AuthSrcPath = Join-Path $PSScriptRoot "..\src\Authentication\" $AuthModulePath = Join-Path $AuthSrcPath "Authentication" -Resolve $TestModulePS1 = Join-Path $PSScriptRoot ".\TestModule.ps1" -Resolve $RunModulePS1 = Join-Path $AuthModulePath ".\run-module.ps1" -Resolve +$CSProjHelperPS1 = Join-Path $PSScriptRoot "./CSProjHelper.ps1" $ModuleMetadataPath = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" [HashTable] $ModuleMetadata = Get-Content $ModuleMetadataPath | ConvertFrom-Json -AsHashTable +# Import scripts +. $CSProjHelperPS1 + if ($null -eq $ModuleMetadata.versions.authentication.version) { Write-Error "Version number is not set for $ModuleFullName module. Please set authentication version in $ModuleMetadataPath." } # Build and pack generated module. if ($Build -or $Run) { + $AuthCoreCSProj = Join-Path $AuthSrcPath "$ModuleName.Core" "$ModuleFullName.Core.csproj" + if ($EnableSigning) { + Set-CSProjValues -ModuleCsProj $AuthCoreCSProj -AssemblyOriginatorKeyFile $SigningKeyFile -ModuleVersion $ModuleMetadata.versions.authentication.version -PreRelease $ModuleMetadata.versions.authentication.prerelease + } + else { + Set-CSProjValues -ModuleCsProj $AuthCoreCSProj -ModuleVersion $ModuleMetadata.versions.authentication.version -PreRelease $ModuleMetadata.versions.authentication.prerelease + } & $BuildModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -EnableSigning:$EnableSigning -Version $ModuleMetadata.versions.authentication.version -Prerelease $ModuleMetadata.versions.authentication.prerelease -ModuleMetadata $ModuleMetadata.Clone() } diff --git a/tools/GenerateModules.ps1 b/tools/GenerateModules.ps1 index 43e2d21accc..95af748072e 100644 --- a/tools/GenerateModules.ps1 +++ b/tools/GenerateModules.ps1 @@ -106,7 +106,11 @@ $ModulesToGenerate | ForEach-Object { Write-Warning "Skipping generation of '$ModuleFullName - $CurrentApiVersion' module." } else { - $FullModuleVersion = "$($ModuleMetadata.versions[$CurrentApiVersion].version)-$($ModuleMetadata.versions[$CurrentApiVersion].prerelease)" + if ($ModuleMetadata.versions[$CurrentApiVersion].prerelease) { + $FullModuleVersion = "$($ModuleMetadata.versions[$CurrentApiVersion].version)-$($ModuleMetadata.versions[$CurrentApiVersion].prerelease)" + } else { + $FullModuleVersion = $ModuleMetadata.versions[$CurrentApiVersion].version + } npx autorest --max-memory-size=$MaxMemorySize --module-version:$FullModuleVersion --module-name:$ModuleFullName --service-name:$Module --input-file:$OpenApiFile $AutoRestModuleConfig if ($LastExitCode -ne 0) { Write-Host -ForegroundColor Red "AutoREST failed to generate '$ModuleFullName' module." diff --git a/tools/ManageGeneratedModule.ps1 b/tools/ManageGeneratedModule.ps1 index e87eb376dc6..65ce9d5edfd 100644 --- a/tools/ManageGeneratedModule.ps1 +++ b/tools/ManageGeneratedModule.ps1 @@ -13,7 +13,7 @@ Param( [Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string]$ModuleSrc, [Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $NamespacePrefix ) -$NugetPackagesToAdd = @("hyak.common") +$NugetPackagesToAdd = @("Hyak.Common") $NugetPackagesToRemove = @("Microsoft.CSharp") $AuthenticationProj = Join-Path $PSScriptRoot "..\src\Authentication\Authentication\Microsoft.Graph.Authentication.csproj" $ModuleCsProj = Join-Path $ModuleSrc "$ModuleName.csproj" diff --git a/tools/NuspecHelper.ps1 b/tools/NuspecHelper.ps1 index ebc53cca3be..f4d8829683a 100644 --- a/tools/NuspecHelper.ps1 +++ b/tools/NuspecHelper.ps1 @@ -66,7 +66,8 @@ function Set-NuSpecValuesFromManifest( function Set-ElementValue( [System.Xml.XmlDocument] $XmlDocument, [System.Xml.XmlElement] $MetadataElement, - [string] $ElementName, [string] $ElementValue) { + [string] $ElementName, + [string] $ElementValue) { if(-not $MetadataElement[$ElementName]){ $NewElement = $XmlDocument.CreateElement($ElementName, $XmlDocument.DocumentElement.NamespaceURI) $MetadataElement.AppendChild($NewElement) | Out-Null @@ -98,6 +99,15 @@ function Set-Dependencies( } } +function Remove-Element( + [System.Xml.XmlDocument] $XmlDocument, + [System.Xml.XmlElement] $MetadataElement, + [string] $ElementName) { + if($MetadataElement[$ElementName]){ + $MetadataElement.RemoveChild($MetadataElement[$ElementName]) + } +} + <# Remove Markdown Docs Element from the Nuspec File. This is fixed in autorest code generator From 49ba4558ab92861f52ba9c4a0a42ec680407701e Mon Sep 17 00:00:00 2001 From: Peter Ombwa Date: Thu, 4 Aug 2022 12:55:07 -0700 Subject: [PATCH 30/30] Lock meta-module version. --- config/ModuleMetadata.json | 1 - src/Graph/beta/Microsoft.Graph.Beta.nuspec | 2 +- src/Graph/beta/Microsoft.Graph.Beta.psd1 | 4 ++-- src/Graph/v1.0/Microsoft.Graph.nuspec | 2 +- src/Graph/v1.0/Microsoft.Graph.psd1 | 6 +++--- tools/GenerateMetaModule.ps1 | 13 ++++++++++--- 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/config/ModuleMetadata.json b/config/ModuleMetadata.json index 5054f51dc17..26b8b1fa6f4 100644 --- a/config/ModuleMetadata.json +++ b/config/ModuleMetadata.json @@ -3,7 +3,6 @@ "authors": "Microsoft", "copyright": "© Microsoft Corporation. All rights reserved.", "description": "Microsoft Graph PowerShell module", - "guid": "fceec1eb-c2e8-4b2b-a120-0fab3f0d7b47", "iconUri": "https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/master/documentation/images/graph_color256.png", "licenseUri": "https://aka.ms/devservicesagreement", "owners": "Microsoft", diff --git a/src/Graph/beta/Microsoft.Graph.Beta.nuspec b/src/Graph/beta/Microsoft.Graph.Beta.nuspec index f78de3b6357..468dc9550ba 100644 --- a/src/Graph/beta/Microsoft.Graph.Beta.nuspec +++ b/src/Graph/beta/Microsoft.Graph.Beta.nuspec @@ -11,7 +11,7 @@ true Microsoft Graph PowerShell module © Microsoft Corporation. All rights reserved. - MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported + MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported PSModule PSIncludes_Cmdlet diff --git a/src/Graph/beta/Microsoft.Graph.Beta.psd1 b/src/Graph/beta/Microsoft.Graph.Beta.psd1 index fe8aba66a0d..99d0f41db8b 100644 --- a/src/Graph/beta/Microsoft.Graph.Beta.psd1 +++ b/src/Graph/beta/Microsoft.Graph.Beta.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 8/3/2022 +# Generated on: 8/4/2022 # @{ @@ -99,7 +99,7 @@ PrivateData = @{ # Tags applied to this module. These help with module discovery in online galleries. Tags = 'MicrosoftGraph', 'Microsoft', 'Office365', 'Graph', 'PowerShell', 'Outlook', 'OneDrive', 'AzureAD', 'SharePoint', 'Intune', - 'AzureAutomationNotSupported' + 'AzureAutomationNotSupported', 'PSModule', 'PSIncludes_Cmdlet' # A URL to the license for this module. LicenseUri = 'https://aka.ms/devservicesagreement' diff --git a/src/Graph/v1.0/Microsoft.Graph.nuspec b/src/Graph/v1.0/Microsoft.Graph.nuspec index 7ee9c766b7f..6149fd125ae 100644 --- a/src/Graph/v1.0/Microsoft.Graph.nuspec +++ b/src/Graph/v1.0/Microsoft.Graph.nuspec @@ -11,7 +11,7 @@ true Microsoft Graph PowerShell module © Microsoft Corporation. All rights reserved. - MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported + MicrosoftGraph Microsoft Office365 Graph PowerShell Outlook OneDrive AzureAD SharePoint Intune AzureAutomationNotSupported PSModule PSIncludes_Cmdlet diff --git a/src/Graph/v1.0/Microsoft.Graph.psd1 b/src/Graph/v1.0/Microsoft.Graph.psd1 index e74e3a2ea2e..5729e23e1c3 100644 --- a/src/Graph/v1.0/Microsoft.Graph.psd1 +++ b/src/Graph/v1.0/Microsoft.Graph.psd1 @@ -3,7 +3,7 @@ # # Generated by: Microsoft # -# Generated on: 8/3/2022 +# Generated on: 8/4/2022 # @{ @@ -18,7 +18,7 @@ ModuleVersion = '1.11.0' CompatiblePSEditions = 'Core', 'Desktop' # ID used to uniquely identify this module -GUID = 'e32ebb56-a940-4829-8105-1459079eaae5' +GUID = 'fceec1eb-c2e8-4b2b-a120-0fab3f0d7b47' # Author of this module Author = 'Microsoft' @@ -98,7 +98,7 @@ PrivateData = @{ # Tags applied to this module. These help with module discovery in online galleries. Tags = 'MicrosoftGraph', 'Microsoft', 'Office365', 'Graph', 'PowerShell', 'Outlook', 'OneDrive', 'AzureAD', 'SharePoint', 'Intune', - 'AzureAutomationNotSupported' + 'AzureAutomationNotSupported', 'PSModule', 'PSIncludes_Cmdlet' # A URL to the license for this module. LicenseUri = 'https://aka.ms/devservicesagreement' diff --git a/tools/GenerateMetaModule.ps1 b/tools/GenerateMetaModule.ps1 index 1be5e32a846..c72fe3a8105 100644 --- a/tools/GenerateMetaModule.ps1 +++ b/tools/GenerateMetaModule.ps1 @@ -86,6 +86,7 @@ $ApiVersion | ForEach-Object { Write-Warning "Module not found in $AuthModuleManifest." } + Write-Host -ForegroundColor Green "Creating '$Module' module manifest..." $ModuleMapping.Keys | ForEach-Object { $RequiredModule = $_ $ModuleManifest = Join-Path $ModulesSrc $RequiredModule $CurrentApiVersion "$Module.$RequiredModule.psd1" @@ -97,17 +98,23 @@ $ApiVersion | ForEach-Object { Write-Warning "Module not found in $ModuleManifest." } } + $ModuleManifestSettings.RequiredModules = $RequiredGraphModules - Write-Host -ForegroundColor Green "Creating '$Module' module manifest..." if ($null -eq $NuspecOptions.version) { Write-Error "Version number is not set for $ModulePrefix module. Please set 'version' in $ModuleMetadataPath." } $ModuleManifestSettings.ModuleVersion = $NuspecOptions.version - $ModuleManifestSettings.Path = "$MetaModuleModuleDir\$CurrentApiVersion\$Module.psd1" - $ModuleManifestSettings.RequiredModules = $RequiredGraphModules if ($NuspecOptions.prerelease) { $ModuleManifestSettings.Prerelease = $NuspecOptions.prerelease } + $ModuleManifestSettings.Path = Join-Path $MetaModuleModuleDir $CurrentApiVersion "$Module.psd1" + if (Test-Path $ModuleManifestSettings.Path) { + $Psd1 = Import-PowerShellDataFile $ModuleManifestSettings.Path + $ModuleManifestSettings.GUID = $Psd1.GUID + } + else { + $ModuleManifestSettings.GUID = (New-Guid).Guid + } New-ModuleManifest @ModuleManifestSettings Write-Host -ForegroundColor Green "Creating '$Module' module nuspec..."