diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml new file mode 100644 index 00000000000..4d43a245465 --- /dev/null +++ b/.azure-pipelines/ci-build.yml @@ -0,0 +1,79 @@ +# 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 + - name: Test + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true + +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 + +jobs: +- job: MsGraphPsSdkCiBuild + displayName: Microsoft Graph PowerShell SDK CI Build + timeoutInMinutes: 840 + steps: + - template: ./common-templates/install-tools.yml + - template: ./common-templates/security-pre-checks.yml + + - template: ./generation-templates/authentication-module.yml + parameters: + Test: ${{ parameters.Test }} + Pack: ${{ parameters.Pack }} + Sign: ${{ parameters.Sign }} + + - template: ./generation-templates/workload-modules.yml + parameters: + Test: ${{ parameters.Test }} + Pack: ${{ parameters.Pack }} + Sign: ${{ parameters.Sign }} + + - template: ./generation-templates/meta-module.yml + parameters: + Test: ${{ parameters.Test }} + Pack: ${{ parameters.Pack }} + Sign: ${{ parameters.Sign }} + + - ${{ if and(eq(parameters.Pack, true), 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' + + - 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 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/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/.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..bec02c4a8cf --- /dev/null +++ b/.azure-pipelines/generation-templates/authentication-module.yml @@ -0,0 +1,51 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +parameters: + - name: Test + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true + +steps: + - task: PowerShell@2 + displayName: Generate Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -EnableSigning:$${{ parameters.Sign }} -Build + + - ${{ if eq(parameters.Test, true) }}: + - task: PowerShell@2 + displayName: Test Authentication Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateAuthenticationModule.ps1 -Test + + - ${{ if eq(parameters.Sign, true) }}: + - template: ../common-templates/esrp/strongname.yml + parameters: + 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)/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 -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/.azure-pipelines/generation-templates/meta-module.yml b/.azure-pipelines/generation-templates/meta-module.yml new file mode 100644 index 00000000000..7e164d27421 --- /dev/null +++ b/.azure-pipelines/generation-templates/meta-module.yml @@ -0,0 +1,38 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +parameters: + - name: Test + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true + +steps: + - task: PowerShell@2 + displayName: 'Generate Meta-Module' + enabled: false + inputs: + targetType: inline + pwsh: true + script: | + $(System.DefaultWorkingDirectory)/tools/GenerateMetaModule.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' + + - ${{ if eq(parameters.Pack, true) }}: + - task: PowerShell@2 + displayName: Pack Meta-Module + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateMetaModule.ps1 -Pack -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/.azure-pipelines/generation-templates/workload-modules.yml b/.azure-pipelines/generation-templates/workload-modules.yml new file mode 100644 index 00000000000..dddf5804936 --- /dev/null +++ b/.azure-pipelines/generation-templates/workload-modules.yml @@ -0,0 +1,51 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. + +parameters: + - name: Test + type: boolean + default: true + - name: Pack + type: boolean + default: true + - name: Sign + type: boolean + default: true + +steps: + - task: PowerShell@2 + displayName: Generate Workload Modules + inputs: + targetType: inline + pwsh: true + script: | + . $(System.DefaultWorkingDirectory)/tools/GenerateModules.ps1 -EnableSigning:$${{ parameters.Sign }} -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 + + - ${{ 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' + + - ${{ 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 -ArtifactsLocation $(Build.ArtifactStagingDirectory) diff --git a/config/ModuleMetadata.json b/config/ModuleMetadata.json index 16f34af3119..26b8b1fa6f4 100644 --- a/config/ModuleMetadata.json +++ b/config/ModuleMetadata.json @@ -1,13 +1,14 @@ { - "guid": "fceec1eb-c2e8-4b2b-a120-0fab3f0d7b47", + "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", @@ -23,7 +24,18 @@ "PSModule", "PSIncludes_Cmdlet" ], - "releaseNotes": "See https://aka.ms/GraphPowerShell-Release.", - "assemblyOriginatorKeyFile": "35MSSharedLib1024.snk", - "version": "1.11.0" -} + "versions": { + "authentication": { + "prerelease": "preview1", + "version": "1.11.0" + }, + "beta": { + "prerelease": "preview1", + "version": "1.11.0" + }, + "v1.0": { + "prerelease": "preview1", + "version": "1.11.0" + } + } +} \ No newline at end of file diff --git a/config/ModulesMapping.jsonc b/config/ModulesMapping.jsonc index 1aa72c1b1a0..5f28ce9aeb7 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$", @@ -33,9 +33,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/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 815e228a062..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,6 +10,8 @@ Microsoft.Graph.Authentication.nuspec © Microsoft Corporation. All rights reserved. + 1.11.0 + preview1 true diff --git a/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec b/src/Authentication/Authentication/Microsoft.Graph.Authentication.nuspec index 53f1515238f..88a880f3107 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.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 957db82afa5..839f10fd25a 100644 --- a/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 +++ b/src/Authentication/Authentication/Microsoft.Graph.Authentication.psd1 @@ -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 = @() @@ -112,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/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 diff --git a/src/Graph/beta/Microsoft.Graph.Beta.nuspec b/src/Graph/beta/Microsoft.Graph.Beta.nuspec new file mode 100644 index 00000000000..468dc9550ba --- /dev/null +++ b/src/Graph/beta/Microsoft.Graph.Beta.nuspec @@ -0,0 +1,22 @@ + + + + Microsoft.Graph.Beta + 1.11.0-preview1 + 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 PSModule PSIncludes_Cmdlet + + + + + + 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..99d0f41db8b --- /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: 8/4/2022 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = '1.11.0' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = '27260379-8df6-41d8-a3ca-067cb8f3ae5d' + +# 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'; 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 = @() + +# 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', 'PSModule', 'PSIncludes_Cmdlet' + + # 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 = 'preview1' + + # 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..6149fd125ae --- /dev/null +++ b/src/Graph/v1.0/Microsoft.Graph.nuspec @@ -0,0 +1,21 @@ + + + + Microsoft.Graph + 1.11.0-preview1 + 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 PSModule PSIncludes_Cmdlet + + + + + 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..5729e23e1c3 --- /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: 8/4/2022 +# + +@{ + +# Script module or binary module file associated with this manifest. +# RootModule = '' + +# Version number of this module. +ModuleVersion = '1.11.0' + +# Supported PSEditions +CompatiblePSEditions = 'Core', 'Desktop' + +# ID used to uniquely identify this module +GUID = 'fceec1eb-c2e8-4b2b-a120-0fab3f0d7b47' + +# 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'; ModuleVersion = '1.11.0'; }, + @{ModuleName = 'Microsoft.Graph.Search'; RequiredVersion = '1.11.0'; }) + +# 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', 'PSModule', 'PSIncludes_Cmdlet' + + # 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 = 'preview1' + + # 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/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: 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 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 diff --git a/tools/BuildModule.ps1 b/tools/BuildModule.ps1 index bfdf27bbc06..a5a9011f0c7 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, + [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] $NuspecMetadata = Get-Content (Join-Path $PSScriptRoot "..\config\ModuleMetadata.json") | ConvertFrom-Json -AsHashTable # Import scripts . $NuspecHelperPS1 . $CSProjHelperPS1 @@ -34,10 +33,10 @@ if (-not (Test-Path -Path $BuildModulePS1)) { # Set delay sign to true. if ($EnableSigning) { - Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleVersion -AssemblyOriginatorKeyFile $NuspecMetadata["assemblyOriginatorKeyFile"] + Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $Version -PreRelease $Prerelease -AssemblyOriginatorKeyFile $ModuleMetadata["assemblyOriginatorKeyFile"] } else { - Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $ModuleVersion -Copyright $NuspecMetadata["copyright"] + Set-CSProjValues -ModuleCsProj $ModuleCsProj -ModuleVersion $Version -PreRelease $Prerelease -Copyright $ModuleMetadata["copyright"] } # Build module @@ -50,29 +49,23 @@ if ($lastexitcode -ne 0) { [HashTable]$ModuleManifestSettings = @{ Path = $ModuleManifest - ModuleVersion = $ModuleVersion - IconUri = $NuspecMetadata["iconUri"] - ReleaseNotes = $ReleaseNotes + ModuleVersion = $Version + IconUri = $ModuleMetadata["iconUri"] + ReleaseNotes = $ModuleMetadata["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 ($RequiredModules.Count -gt 0) { + $ModuleManifestSettings["RequiredModules"] = $RequiredModules +} + +if ($Prerelease) { + $ModuleManifestSettings.Prerelease = $Prerelease + $FullVersionNumber = "$Version-$Prerelease" } else { - if ($RequiredModules.Count -gt 0) { - $ModuleManifestSettings["RequiredModules"] = $RequiredModules - } + $FullVersionNumber = $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..f2bb6c955f6 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, + [string] $PreRelease, [string] $Copyright, [string] $AssemblyOriginatorKeyFile) { $NuspecHelperPS1 = Join-Path $PSScriptRoot "./NuspecHelper.ps1" @@ -28,8 +29,17 @@ 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 + 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) Write-Host "Updated the $ModuleCsProj." -} \ No newline at end of file +} diff --git a/tools/GenerateAuthenticationModule.ps1 b/tools/GenerateAuthenticationModule.ps1 index 884aaef3aa4..9ee1d291e77 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.' } @@ -29,67 +23,48 @@ if ($PSEdition -ne 'Core') { $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" +$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." } -$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." -} -elseif ($VersionState.Equals([VersionState]::EqualToFeed) -and !$BuildWhenEqual) { - Write-Warning "$ModuleFullName module skipped. Version has not changed and is equal to what's on $RepositoryName." -} -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 - } +# 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 } - if ($Test) { - & $TestModulePS1 -ModulePath (Join-Path $AuthModulePath "artifacts" ) -ModuleName "$ModuleFullName" -ModuleTestsPath (Join-Path $AuthModulePath "test") + 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() +} - if ($Pack -or $Run) { - & $PackModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -Module $ModuleName -ArtifactsLocation $ArtifactsLocation - } +if ($Test) { + & $TestModulePS1 -ModulePath (Join-Path $AuthModulePath "artifacts" ) -ModuleName "$ModuleFullName" -ModuleTestsPath (Join-Path $AuthModulePath "test") +} - if ($Run) { - & $RunModulePS1 -ModuleName "$ModuleFullName" -ArtifactLocation $ArtifactsLocation - } +if ($Pack -or $Run) { + & $PackModulePS1 -ModuleFullName $ModuleFullName -ModuleSrc $AuthModulePath -Module $ModuleName -ArtifactsLocation $ArtifactsLocation +} - if ($Publish) { - & $PublishModulePS1 -Modules $ModuleName -ModulePrefix $ModulePrefix -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey - } +if ($Run) { + & $RunModulePS1 -ModuleName "$ModuleFullName" -ArtifactLocation $ArtifactsLocation +} + +if ($Publish) { + & $PublishModulePS1 -Modules $ModuleName -ModulePrefix $ModulePrefix -ArtifactsLocation $ArtifactsLocation -RepositoryName $RepositoryName -RepositoryApiKey $RepositoryApiKey } diff --git a/tools/GenerateMetaModule.ps1 b/tools/GenerateMetaModule.ps1 new file mode 100644 index 00000000000..c72fe3a8105 --- /dev/null +++ b/tools/GenerateMetaModule.ps1 @@ -0,0 +1,146 @@ + +# 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\"), + [switch] $Pack, + [switch] $Publish +) +$ErrorActionPreference = 'Stop' +$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.' +} + +$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 +$ModuleMetadataPath = Join-Path $PSScriptRoot "..\config\ModuleMetadata.json" -Resolve +$ModulesSrc = Join-Path $PSScriptRoot "..\src" +$MetaModuleModuleDir = Join-Path $ModulesSrc "Graph" +[HashTable] $ModuleMapping = Get-Content $ModuleMappingPath | ConvertFrom-Json -AsHashTable +[HashTable] $ModuleMetadata = Get-Content $ModuleMetadataPath | ConvertFrom-Json -AsHashTable +$ModuleMetadata.Remove("assemblyOriginatorKeyFile") + +# Import scripts +. $NuspecHelperPS1 + +$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 +} + +[HashTable]$ModuleManifestSettings = @{ + CompatiblePSEditions = "Core", "Desktop" + PowerShellVersion = "5.1" + DotNetFrameworkVersion = "4.7.2" + 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 = @() +} + +# 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() + $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) { + $RequiredGraphModules += @{ ModuleName = $LoadedAuthModule.Name ; ModuleVersion = $LoadedAuthModule.Version } + } + else { + 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" + $LoadedModule = Import-Module $ModuleManifest -PassThru -ErrorAction SilentlyContinue + if ($null -ne $LoadedModule) { + $RequiredGraphModules += @{ ModuleName = $LoadedModule.Name ; RequiredVersion = $LoadedModule.Version; } + } + else { + Write-Warning "Module not found in $ModuleManifest." + } + } + $ModuleManifestSettings.RequiredModules = $RequiredGraphModules + + if ($null -eq $NuspecOptions.version) { + Write-Error "Version number is not set for $ModulePrefix module. Please set 'version' in $ModuleMetadataPath." + } + $ModuleManifestSettings.ModuleVersion = $NuspecOptions.version + 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..." + $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 + } + + 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 23dbe22754d..95af748072e 100644 --- a/tools/GenerateModules.ps1 +++ b/tools/GenerateModules.ps1 @@ -4,9 +4,9 @@ Param( $ModulesToGenerate = @(), [ValidateSet("v1.0", "beta")] - $ApiVersionToGenerate = @("v1.0", "beta"), + $ApiVersion = @("v1.0", "beta"), [string] $RepositoryName = "PSGallery", - [int] $ModulePreviewNumber = -1, + [string] $ArtifactsLocation = (Join-Path $PSScriptRoot "..\artifacts\"), [switch] $SkipGeneration = $false, [switch] $Build, [switch] $Test, @@ -42,50 +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\" -$ArtifactsLocation = Join-Path $ScriptRoot "..\artifacts" +$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,41 +82,36 @@ $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." - } - - $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" - 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 - $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 + 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." exit $LastExitCode @@ -141,12 +125,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/GenerateRollUpModule.ps1 b/tools/GenerateRollUpModule.ps1 index bcbd2570474..58c2eb815e7 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 = @() 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 4b650166c9c..f4d8829683a 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") @@ -58,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 @@ -80,12 +89,25 @@ 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 } } +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 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