From c9bcc51d6edb7825ec229f085ece4c957e2e6345 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Tue, 3 Feb 2026 15:56:00 -0800 Subject: [PATCH 1/3] Update build and release pipeline --- .config/tsaoptions.json | 10 + .github/workflows/ci-test.yml | 51 +++ .../PSDesiredStateConfiguration-OneBranch.yml | 155 +++++++ .vsts-ci/azure-pipelines-ci.yml | 164 -------- .vsts-ci/azure-pipelines-release.yml | 205 ---------- .vsts-ci/misc-analysis.yml | 19 - .vsts-ci/templates/ci-build.yml | 16 - .vsts-ci/templates/ci-test.yml | 122 ------ .vsts-ci/templates/credscan.yml | 31 -- .vsts-ci/templates/shouldsign.yml | 17 - LICENSE | 21 + assets/powershell.config.json | 10 +- build.ps1 | 101 ++--- dobuild.ps1 | 53 +-- psdesiredstateconfiguration.nuspec | 17 - pspackageproject.json | 9 - test/PSDesiredStateConfiguration.Tests.ps1 | 55 +-- test/configuration.Tests.ps1 | 4 +- tools/installPSResources.ps1 | 24 ++ tools/releaseBuild/FileCatalogSigning.xml | 6 - tools/releaseBuild/generatePackgeSigning.ps1 | 100 ----- tools/releaseBuild/packagesigning.xml | 6 - tools/releaseBuild/signing.xml | 9 - tools/terms/FileTypeSet.xml | 379 ------------------ updateSigningXml.ps1 | 7 - 25 files changed, 364 insertions(+), 1227 deletions(-) create mode 100644 .config/tsaoptions.json create mode 100644 .github/workflows/ci-test.yml create mode 100644 .pipelines/PSDesiredStateConfiguration-OneBranch.yml delete mode 100644 .vsts-ci/azure-pipelines-ci.yml delete mode 100644 .vsts-ci/azure-pipelines-release.yml delete mode 100644 .vsts-ci/misc-analysis.yml delete mode 100644 .vsts-ci/templates/ci-build.yml delete mode 100644 .vsts-ci/templates/ci-test.yml delete mode 100644 .vsts-ci/templates/credscan.yml delete mode 100644 .vsts-ci/templates/shouldsign.yml create mode 100644 LICENSE delete mode 100644 psdesiredstateconfiguration.nuspec delete mode 100644 pspackageproject.json create mode 100644 tools/installPSResources.ps1 delete mode 100644 tools/releaseBuild/FileCatalogSigning.xml delete mode 100644 tools/releaseBuild/generatePackgeSigning.ps1 delete mode 100644 tools/releaseBuild/packagesigning.xml delete mode 100644 tools/releaseBuild/signing.xml delete mode 100644 tools/terms/FileTypeSet.xml delete mode 100644 updateSigningXml.ps1 diff --git a/.config/tsaoptions.json b/.config/tsaoptions.json new file mode 100644 index 0000000..f85064e --- /dev/null +++ b/.config/tsaoptions.json @@ -0,0 +1,10 @@ +{ + "instanceUrl": "https://msazure.visualstudio.com", + "projectName": "One", + "areaPath": "One\\MGMT\\Compute\\Powershell\\Powershell\\PowerShell Core", + "notificationAliases": [ + "andschwa@microsoft.com", + "slee@microsoft.com" + ], + "codebaseName": "PSDSC_202502" +} diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml new file mode 100644 index 0000000..0f94ca0 --- /dev/null +++ b/.github/workflows/ci-test.yml @@ -0,0 +1,51 @@ +name: CI Tests + +on: + push: + branches: [ v2 ] + pull_request: + branches: [ v2 ] + +jobs: + ci: + name: pester + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install PSResources + run: ./tools/installPSResources.ps1 + shell: pwsh + + - name: Build + run: ./build.ps1 -Build + shell: pwsh + + - name: Test + run: ./build.ps1 -Test + shell: pwsh + + - name: Test Windows PowerShell + run: | + Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck + ./build.ps1 -Test + shell: powershell + + - name: Package + run: ./build.ps1 -Publish + shell: pwsh + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + if: always() + with: + name: PSDesiredStateConfiguration-package + path: out/**/*.nupkg + + - name: Upload test results + uses: actions/upload-artifact@v4 + if: always() + with: + name: PSDesiredStateConfiguration-tests + path: out/testResults.xml diff --git a/.pipelines/PSDesiredStateConfiguration-OneBranch.yml b/.pipelines/PSDesiredStateConfiguration-OneBranch.yml new file mode 100644 index 0000000..8a0dc6f --- /dev/null +++ b/.pipelines/PSDesiredStateConfiguration-OneBranch.yml @@ -0,0 +1,155 @@ +trigger: +- main + +schedules: +- cron: '18 11 * * 5' + displayName: Weekly CodeQL + branches: + include: + - main + always: true + +parameters: +- name: debug + displayName: Enable debug output + type: boolean + default: false +- name: OfficialBuild + displayName: Use Official OneBranch template + type: boolean + default: true +- name: Release + displayName: Generate a release + type: boolean + default: false + +variables: + system.debug: ${{ parameters.debug }} + BuildConfiguration: Release + WindowsContainerImage: onebranch.azurecr.io/windows/ltsc2022/vse2022:latest + OneBranchTemplate: ${{ iif(parameters.OfficialBuild, 'v2/OneBranch.Official.CrossPlat.yml@templates', 'v2/OneBranch.NonOfficial.CrossPlat.yml@templates') }} + +resources: + repositories: + - repository: templates + type: git + name: OneBranch.Pipelines/GovernedTemplates + ref: refs/heads/main + +extends: + # https://aka.ms/obpipelines/templates + template: ${{ variables.OneBranchTemplate }} + parameters: + globalSdl: # https://aka.ms/obpipelines/sdl + asyncSdl: + enabled: true + forStages: [build] + featureFlags: + EnableCDPxPAT: false + WindowsHostVersion: + Version: 2022 + Network: KS3 + release: + category: NonAzure + stages: + - stage: build + jobs: + - job: main + displayName: Build package + pool: + type: windows + variables: + ob_outputDirectory: $(Build.SourcesDirectory)/out + steps: + - pwsh: | + $manifest = Import-PowerShellDataFile ./src/PSDesiredStateConfiguration/PSDesiredStateConfiguration.psd1 + $version = $manifest.ModuleVersion + Write-Output "##vso[task.setvariable variable=version;isOutput=true]$version" + name: package + displayName: Get version from module manifest + - task: onebranch.pipeline.version@1 + displayName: Set OneBranch version + inputs: + system: Custom + customVersion: $(package.version) + - pwsh: ./tools/installPSResources.ps1 -PSRepository CFS + displayName: Install PSResources + - pwsh: ./build.ps1 -Clean -Build -Test + displayName: Build + - task: onebranch.pipeline.signing@1 + displayName: Sign 1st-party files + inputs: + command: sign + signing_profile: external_distribution + search_root: $(Build.SourcesDirectory)/out + files_to_sign: | + **/*.psd1; + **/*.psm1; + - pwsh: ./build.ps1 -Publish + displayName: Package module + - task: onebranch.pipeline.signing@1 + displayName: Sign NuGet package + inputs: + command: sign + signing_profile: external_distribution + search_root: $(Build.SourcesDirectory)/out + files_to_sign: | + *.nupkg + - stage: release + dependsOn: build + condition: and(succeeded(), ${{ eq(parameters.Release, true) }}) + variables: + ob_release_environment: ${{ iif(parameters.OfficialBuild, 'Production', 'Test') }} + version: $[ stageDependencies.build.main.outputs['package.version'] ] + jobs: + - job: github + displayName: Publish draft to GitHub + pool: + type: release + templateContext: + inputs: + - input: pipelineArtifact + artifactName: drop_build_main + steps: + - task: GitHubRelease@1 + displayName: Create GitHub release + inputs: + gitHubConnection: GitHub + repositoryName: PowerShell/PSDesiredStateConfiguration + target: main + assets: $(Pipeline.Workspace)/PSDesiredStateConfiguration.$(version).nupkg + tagSource: userSpecifiedTag + tag: $(version) + isDraft: true + addChangeLog: false + releaseNotesSource: inline + releaseNotesInline: "" + - job: validation + displayName: Manual validation + pool: + type: server + timeoutInMinutes: 1440 + steps: + - task: ManualValidation@0 + displayName: Wait 24 hours for validation + inputs: + notifyUsers: $(Build.RequestedForEmail) + instructions: Please validate the release and then publish it! + timeoutInMinutes: 1440 + - job: publish + dependsOn: validation + displayName: Publish to PowerShell Gallery + pool: + type: release + templateContext: + inputs: + - input: pipelineArtifact + artifactName: drop_build_main + steps: + - task: NuGetCommand@2 + displayName: Publish module to PowerShell Gallery + inputs: + command: push + packagesToPush: $(Pipeline.Workspace)/PSDesiredStateConfiguration.$(version).nupkg + nuGetFeedType: external + publishFeedCredentials: PowerShellGallery diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml deleted file mode 100644 index 8a436a0..0000000 --- a/.vsts-ci/azure-pipelines-ci.yml +++ /dev/null @@ -1,164 +0,0 @@ -name: Build-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) -trigger: - # Batch merge builds together while a merge build is running - batch: true - branches: - include: - - master -pr: - branches: - include: - - master - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - -stages: -- stage: Build - displayName: Build PSDesiredStateConfiguration module - pool: - name: Package ES CodeHub Lab E - jobs: - - job: BuildPkg - displayName: Build Package - variables: - - group: ESRP - steps: - - powershell: | - $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' - Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1 - ./install-powershell.ps1 -Destination $powerShellPath - $vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Install PowerShell Core - - - task: NuGetToolInstaller@1 - displayName: 'Install NuGet 5.9.1' - inputs: - checkLatest: false - version: 5.9.1 - - - pwsh: | - Get-ChildItem -Path env: - displayName: Capture environment for build - condition: succeededOrFailed() - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - if (Test-Path -Path $modulePath) { - Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" - Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore - } - if (! (Test-Path -Path $modulePath)) { - Write-Verbose -Verbose "Creating new temp module path: $modulePath" - $null = New-Item -Path $modulePath -ItemType Directory - } - displayName: Create temporary module path - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path" - Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force - Write-Verbose -Verbose "Install PlatyPS to temp module path" - Save-Module -Name "platyPS" -Path $modulePath -Force - Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path" - Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force - Write-Verbose -Verbose "Install Pester 4.X to temp module path" - Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force - Write-Verbose -Verbose "Install PSPackageProject to temp module path" - Save-Module -Name PSPackageProject -Path $modulePath -Force - displayName: Install PSPackageProject and dependencies - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject - Write-Verbose -Verbose "Importing PSPackageProject from: $modPath" - Import-Module -Name $modPath -Force - # - $(Build.SourcesDirectory)/build.ps1 -Build -Clean - displayName: Execute build - - - pwsh: | - $signSrcPath = "$(Build.SourcesDirectory)\out\PSDesiredStateConfiguration" - # Set signing src path variable - $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - $signOutPath = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration" - $null = New-Item -ItemType Directory -Path $signOutPath - # Set signing out path variable - $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - # Set path variable for guardian codesign validation - $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Setup variables for signing - - - template: EsrpSign.yml@ComplianceRepo - parameters: - # the folder which contains the binaries to sign - buildOutputPath: $(signSrcPath) - # the location to put the signed output - signOutputPath: $(signOutPath) - # the certificate ID to use - certificateId: "CP-230012" - # the file pattern to use, comma separated - pattern: '*.psm1,*.psd1' - - - pwsh: | - $repoName = [guid]::newGuid().ToString("N") - $packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration" - Register-PSRepository -Name $repoName -SourceLocation $packageRoot -InstallationPolicy Trusted - Publish-Module -Path $packageRoot -Repository $repoName - Unregister-PSRepository -Name $repoName - Get-ChildItem -Recurse -Path $packageRoot | Write-Verbose -Verbose - $nupkgPath = (Get-ChildItem -Recurse -Path $packageRoot -Filter "PSDesiredStateConfiguration*.nupkg" | select -First 1).FullName - Write-Host "##vso[artifact.upload containerfolder=nupkg;artifactname=nupkg]$nupkgPath" - displayName: Package and publish nupkg - name: ProduceNupkg - - - publish: "$(signSrcPath)" - artifact: Build - displayName: Publish build - - - publish: "$(signOutPath)" - artifact: SignedBuild - displayName: Publish signed build - -- stage: Compliance - displayName: Compliance - dependsOn: Build - jobs: - - job: Compliance_Job - pool: - name: Package ES CodeHub Lab E - steps: - - checkout: self - - checkout: ComplianceRepo - - download: current - artifact: SignedBuild - - - pwsh: | - Get-ChildItem -Path "$(Pipeline.Workspace)\SignedBuild" -Recurse - displayName: Capture downloaded artifacts - - template: ci-compliance.yml@ComplianceRepo - parameters: - # component-governance - sourceScanPath: '$(Pipeline.Workspace)\SignedBuild' - # credscan - suppressionsFile: '' - # TermCheck - optionsRulesDBPath: '' - optionsFTPath: '' - # tsa-upload - codeBaseName: 'PSDesiredStateConfiguration_20210423' - # selections - APIScan: false # set to false when not using Windows APIs. diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml deleted file mode 100644 index 5e43127..0000000 --- a/.vsts-ci/azure-pipelines-release.yml +++ /dev/null @@ -1,205 +0,0 @@ -name: $(BuildDefinitionName)_$(date:yyMM).$(date:dd)$(rev:rrr) - -trigger: none - -resources: - repositories: - - repository: ComplianceRepo - type: github - endpoint: ComplianceGHRepo - name: PowerShell/compliance - -variables: - - name: PackageName - value: 'PSDesiredStateConfiguration' - - name: PackageVersion - value: '2.0.6' - -stages: -- stage: Build - displayName: Build PSDesiredStateConfiguration module - pool: - name: PowerShell1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - jobs: - - job: BuildPkg - displayName: Build Package - variables: - - group: ESRP - steps: - - powershell: | - $powerShellPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'powershell' - Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1 - ./install-powershell.ps1 -Preview -Destination $powerShellPath - $vstsCommandString = "vso[task.setvariable variable=PATH]$powerShellPath;$env:PATH" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Install PowerShell Core - - - task: NuGetToolInstaller@1 - displayName: 'Install NuGet' - inputs: - checkLatest: false - version: 5.9.1 - - - pwsh: | - Get-ChildItem -Path env: - displayName: Capture environment for build - condition: succeededOrFailed() - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - if (Test-Path -Path $modulePath) { - Write-Verbose -Verbose "Deleting existing temp module path: $modulePath" - Remove-Item -Path $modulePath -Recurse -Force -ErrorAction Ignore - } - if (! (Test-Path -Path $modulePath)) { - Write-Verbose -Verbose "Creating new temp module path: $modulePath" - $null = New-Item -Path $modulePath -ItemType Directory - } - displayName: Create temporary module path - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - Write-Verbose -Verbose "Install PowerShellGet V3 to temp module path" - Save-Module -Name PowerShellGet -Path $modulePath -MinimumVersion 3.0.0-beta10 -AllowPrerelease -Force - Write-Verbose -Verbose "Install PlatyPS to temp module path" - Save-Module -Name "platyPS" -Path $modulePath -Force - Write-Verbose -Verbose "Install PSScriptAnalyzer to temp module path" - Save-Module -Name "PSScriptAnalyzer" -Path $modulePath -RequiredVersion 1.18.0 -Force - Write-Verbose -Verbose "Install Pester 4.X to temp module path" - Save-Module -Name "Pester" -MaximumVersion 4.99 -Path $modulePath -Force - Write-Verbose -Verbose "Install PSPackageProject to temp module path" - Save-Module -Name PSPackageProject -Path $modulePath -Force - displayName: Install PSPackageProject and dependencies - - - pwsh: | - $modulePath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath 'TempModules' - $env:PSModulePath = $modulePath + [System.IO.Path]::PathSeparator + $env:PSModulePath - $modPath = Join-Path -Path $modulePath -ChildPath PSPackageProject - Write-Verbose -Verbose "Importing PSPackageProject from: $modPath" - Import-Module -Name $modPath -Force - # - $(Build.SourcesDirectory)/build.ps1 -Build -Clean - displayName: Execute build - - - pwsh: | - $signSrcPath = "$(Build.SourcesDirectory)\out\PSDesiredStateConfiguration" - # Set signing src path variable - $vstsCommandString = "vso[task.setvariable variable=signSrcPath]${signSrcPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - $signOutPath = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration" - $null = New-Item -ItemType Directory -Path $signOutPath - # Set signing out path variable - $vstsCommandString = "vso[task.setvariable variable=signOutPath]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - # Set path variable for guardian codesign validation - $vstsCommandString = "vso[task.setvariable variable=GDN_CODESIGN_TARGETDIRECTORY]${signOutPath}" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Setup variables for signing - - - template: EsrpSign.yml@ComplianceRepo - parameters: - # the folder which contains the binaries to sign - buildOutputPath: $(signSrcPath) - # the location to put the signed output - signOutputPath: $(signOutPath) - # the certificate ID to use - certificateId: "CP-230012" - # the file pattern to use, comma separated - pattern: '*.psm1,*.psd1' - - - template: Sbom.yml@ComplianceRepo - parameters: - BuildDropPath: "$(Build.SourcesDirectory)/signed/PSDesiredStateConfiguration" - Build_Repository_Uri: 'https://github.com/PowerShell/PSDesiredStateConfiguration' - PackageName: $(PackageName) - PackageVersion: $(PackageVersion) - - - pwsh: | - $repoName = [guid]::newGuid().ToString("N") - $packageRoot = "$(Build.SourcesDirectory)\signed\PSDesiredStateConfiguration" - Register-PSRepository -Name $repoName -SourceLocation $packageRoot -InstallationPolicy Trusted - Publish-Module -Path $packageRoot -Repository $repoName - Unregister-PSRepository -Name $repoName - Get-ChildItem -Recurse -Path $packageRoot | Write-Verbose -Verbose - $nupkgPath = (Get-ChildItem -Recurse -Path $packageRoot -Filter "PSDesiredStateConfiguration*.nupkg" | select -First 1).FullName - Write-Host "##vso[artifact.upload containerfolder=nupkg;artifactname=nupkg]$nupkgPath" - displayName: Package and publish nupkg - name: ProduceNupkg - - - publish: "$(signSrcPath)" - artifact: Build - displayName: Publish build - - - publish: "$(signOutPath)" - artifact: SignedBuild - displayName: Publish signed build - -- stage: Compliance - displayName: Compliance - dependsOn: Build - jobs: - - job: Compliance_Job - pool: - name: PowerShell1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - steps: - - checkout: self - - checkout: ComplianceRepo - - download: current - artifact: SignedBuild - - - pwsh: | - Get-ChildItem -Path "$(Pipeline.Workspace)\SignedBuild" -Recurse - displayName: Capture downloaded artifacts - - template: script-module-compliance.yml@ComplianceRepo - parameters: - # component-governance - sourceScanPath: '$(Pipeline.Workspace)\SignedBuild' - # credscan - suppressionsFile: '' - # TermCheck - optionsRulesDBPath: '' - optionsFTPath: '' - # tsa-upload - codeBaseName: 'PSDesiredStateConfiguration_20210423' - # selections - APIScan: false # set to false when not using Windows APIs. - -- stage: Deploy - displayName: Publish to PowerShell gallery - dependsOn: - - Build - - Compliance - jobs: - - deployment: DeployPowerShellGallery - displayName: Deploy nupkg to PowerShell Gallery - pool: - name: PowerShell1ES - demands: - - ImageOverride -equals PSMMS2019-Secure - environment: 'PSDesiredStateConfiguration-ReleaseApproval' - strategy: - runOnce: - deploy: - steps: - - download: current - artifact: 'nupkg' - - task: NuGetToolInstaller@1 - displayName: 'Install NuGet' - inputs: - checkLatest: false - version: 5.9.1 - - task: NuGetCommand@2 - displayName: 'NuGet push' - inputs: - command: push - packagesToPush: '$(Pipeline.Workspace)\nupkg\PSDesiredStateConfiguration.*.nupkg' - nuGetFeedType: external - publishFeedCredentials: 'PowerShellGallery' diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml deleted file mode 100644 index e8ccba8..0000000 --- a/.vsts-ci/misc-analysis.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) -trigger: - # Batch merge builds together while a merge build is running - batch: true - branches: - include: - - master - -pr: - branches: - include: - - master - -resources: -- repo: self - clean: true - -jobs: -- template: templates/credscan.yml diff --git a/.vsts-ci/templates/ci-build.yml b/.vsts-ci/templates/ci-build.yml deleted file mode 100644 index 1d2f896..0000000 --- a/.vsts-ci/templates/ci-build.yml +++ /dev/null @@ -1,16 +0,0 @@ -steps: -- pwsh: | - Install-Module -Name "platyPS","Pester" -Force - displayName: Install dependencies - timeoutInMinutes: 10 -- pwsh: | - Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force - displayName: Install PSScriptAnalyzer - timeoutInMinutes: 10 -- pwsh: | - Install-Module -Name PSPackageProject -Force - displayName: Install PSPackageProject module - timeoutInMinutes: 10 -- pwsh: | - $(Build.SourcesDirectory)/build.ps1 -Build - displayName: Build diff --git a/.vsts-ci/templates/ci-test.yml b/.vsts-ci/templates/ci-test.yml deleted file mode 100644 index 898e213..0000000 --- a/.vsts-ci/templates/ci-test.yml +++ /dev/null @@ -1,122 +0,0 @@ -parameters: - jobName: TestPkgWin - imageName: windows-2019 - displayName: PowerShell Core on Windows - powershellExecutable: pwsh - -jobs: -- job: ${{ parameters.jobName }} - pool: - vmImage: ${{ parameters.imageName }} - displayName: ${{ parameters.displayName }} - steps: - - ${{ parameters.powershellExecutable }}: | - if($IsMacOs) - { - brew install powershell/tap/powershell-preview - sudo ln -s -f /usr/local/opt/powershell-preview/libexec/pwsh /usr/local/bin/pwsh - } - elseif($IsLinux) - { - sudo apt-get update - sudo apt-get install powershell-preview - sudo ln -s /opt/microsoft/powershell/7-preview/pwsh /usr/local/bin/pwsh - } - elseif($IsWindows) - { - Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.ps1 -outfile ./install-powershell.ps1 - ./install-powershell.ps1 -AddToPath -Preview -Destination C:\powershell-preview - $vstsCommandString = "vso[task.setvariable variable=PATH]C:\powershell-preview;$env:PATH" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - } - displayName: Setup PowerShell preview - - - ${{ parameters.powershellExecutable }}: | - $PSVersionTable - $vstsCommandString = "vso[task.setvariable variable=PSHOME]$pshome" - Write-Host "sending " + $vstsCommandString - Write-Host "##$vstsCommandString" - displayName: Capture PowerShellVersion - - - ${{ parameters.powershellExecutable }}: | - dir env:PATH - displayName: Capture Path - - - ${{ parameters.powershellExecutable }}: | - Get-PSRepository - displayName: Capture PSRepository - - - ${{ parameters.powershellExecutable }}: | - Install-module Pester -Force -MaximumVersion 4.99 - displayName: Install dependencies - Pester - timeoutInMinutes: 10 - - - ${{ parameters.powershellExecutable }}: | - Install-Module -Name "platyPS" -Force - displayName: Install dependencies - PlatyPS - timeoutInMinutes: 10 - - - ${{ parameters.powershellExecutable }}: | - Install-Module -Name "PSScriptAnalyzer" -RequiredVersion 1.18.0 -Force - displayName: Install dependencies - PSScriptAnalyzer - timeoutInMinutes: 10 - - - ${{ parameters.powershellExecutable }}: | - Install-Module -Name PSPackageProject -Force - displayName: Install PSPackageProject module - - - ${{ parameters.powershellExecutable }}: | - Get-InstalledModule -Name pester -AllVersions | Where-Object {$_.Version -ge ([version]::new(5,0,0))} | Uninstall-Module -Force - displayName: Remove >= 5.0.0 Pester - - - task: DownloadBuildArtifacts@0 - displayName: 'Download artifacts' - inputs: - buildType: current - downloadType: specific - itemPattern: '**/*.nupkg' - downloadPath: '$(System.ArtifactsDirectory)' - - - ${{ parameters.powershellExecutable }}: | - $sourceName = 'pspackageproject-local-repo' - Register-PSRepository -Name $sourceName -SourceLocation '$(System.ArtifactsDirectory)' -ErrorAction Ignore - $config = Get-PSPackageProjectConfiguration - $buildOutputPath = $config.BuildOutputPath - $null = New-Item -ItemType Directory -Path $buildOutputPath -Verbose - $moduleName = $config.ModuleName - Save-Module -Repository $sourceName -Name $moduleName -Path $config.BuildOutputPath - displayName: Extract product artifact - timeoutInMinutes: 10 - - - ${{ parameters.powershellExecutable }}: | - Invoke-PSPackageProjectTest -Type Functional - displayName: Execute functional tests - InvokeDscResource Disabled - errorActionPreference: continue - - - ${{ parameters.powershellExecutable }}: | - $configFolder = split-path $PROFILE - $configPath = Join-Path $configFolder -ChildPath powershell.config.json - copy-Item $(Build.SourcesDirectory)/assets/powershell.config.json $configPath - displayName: Enable ExperimentalFeature - errorActionPreference: continue - - - ${{ parameters.powershellExecutable }}: | - Invoke-PSPackageProjectTest -Type Functional - displayName: Execute functional tests - InvokeDscResource Enabled - errorActionPreference: continue - - - ${{ parameters.powershellExecutable }}: | - Invoke-PSPackageProjectTest -Type StaticAnalysis - displayName: Execute static analysis tests - # need to figure out how to disable PSAvoidOverwritingBuiltInCmdlets - continueOnError: true - errorActionPreference: continue - condition: succeededOrFailed() - - - - ${{ parameters.powershellExecutable }}: | - Unregister-PSRepository -Name 'pspackageproject-local-repo' -ErrorAction Ignore - displayName: Unregister temporary PSRepository - condition: always() - timeoutInMinutes: 10 diff --git a/.vsts-ci/templates/credscan.yml b/.vsts-ci/templates/credscan.yml deleted file mode 100644 index eb711c8..0000000 --- a/.vsts-ci/templates/credscan.yml +++ /dev/null @@ -1,31 +0,0 @@ -parameters: - pool: 'Hosted VS2017' - jobName: 'credscan' - displayName: Secret Scan - -jobs: -- job: ${{ parameters.jobName }} - pool: - name: ${{ parameters.pool }} - - displayName: ${{ parameters.displayName }} - - steps: - - powershell: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))" - displayName: Set Build Name for Non-PR - condition: ne(variables['Build.Reason'], 'PullRequest') - - - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 - displayName: 'Scan for secrets' - inputs: - debugMode: false - - - task: securedevelopmentteam.vss-secure-development-tools.build-task-publishsecurityanalysislogs.PublishSecurityAnalysisLogs@2 - displayName: 'Publish Secret Scan Logs to Build Artifacts' - continueOnError: true - - - task: securedevelopmentteam.vss-secure-development-tools.build-task-postanalysis.PostAnalysis@1 - displayName: 'Check for failures' - inputs: - CredScan: true - ToolLogsNotFoundAction: Error diff --git a/.vsts-ci/templates/shouldsign.yml b/.vsts-ci/templates/shouldsign.yml deleted file mode 100644 index e92475e..0000000 --- a/.vsts-ci/templates/shouldsign.yml +++ /dev/null @@ -1,17 +0,0 @@ -steps: -- powershell: | - $shouldSign = $true - if($env:BUILD_REASON -ne 'Manual') - { - $shouldSign = $false - } - - if($env:SKIP_SIGNING -eq 'Yes') - { - $shouldSign = $false - } - - $vstsCommandString = "vso[task.setvariable variable=SHOULD_SIGN]$($shouldSign.ToString().ToLowerInvariant())" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" - displayName: 'Set SHOULD_SIGN Variable' diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..48ea661 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE diff --git a/assets/powershell.config.json b/assets/powershell.config.json index 8b78121..76bc675 100644 --- a/assets/powershell.config.json +++ b/assets/powershell.config.json @@ -1 +1,9 @@ -{"ExperimentalFeatures":["PSCommandNotFoundSuggestion","PSForEachObjectParallel","PSImplicitRemotingBatching","Microsoft.PowerShell.Utility.PSDebugRunspaceWithBreakpoints","PSDesiredStateConfiguration.InvokeDscResource"]} +{ + "ExperimentalFeatures": [ + "PSCommandNotFoundSuggestion", + "PSForEachObjectParallel", + "PSImplicitRemotingBatching", + "Microsoft.PowerShell.Utility.PSDebugRunspaceWithBreakpoints", + "PSDesiredStateConfiguration.InvokeDscResource" + ] +} diff --git a/build.ps1 b/build.ps1 index 6d8fa5c..268bf63 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,7 +1,6 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. +# Copyright (c) Microsoft Corporation. # Licensed under the MIT License. -# Do NOT edit this file. Edit dobuild.ps1 [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")] param ( [Parameter(ParameterSetName="build")] @@ -15,9 +14,6 @@ param ( [Parameter(ParameterSetName="publish")] [switch] $Publish, - [Parameter(ParameterSetName="publish")] - [switch] - $Signed, [Parameter(ParameterSetName="build")] [switch] @@ -37,34 +33,15 @@ param ( $TestInvokeDscResource ) -$config = Get-PSPackageProjectConfiguration -ConfigPath $PSScriptRoot - -$script:ModuleName = $config.ModuleName -$script:SrcPath = $config.SourcePath -$script:OutDirectory = $config.BuildOutputPath -$script:SignedDirectory = $config.SignedOutputPath -$script:TestPath = $config.TestPath - -$script:ModuleRoot = $PSScriptRoot -$script:Culture = $config.Culture -$script:HelpPath = $config.HelpPath - -if ($env:TF_BUILD) { - $vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" - - $vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory" - Write-Host ("sending " + $vstsCommandString) - Write-Host "##$vstsCommandString" -} +# Build configuration +$script:ModuleName = "PSDesiredStateConfiguration" +$script:SrcPath = Join-Path (Join-Path $PSScriptRoot "src") $ModuleName +$script:OutDirectory = Join-Path $PSScriptRoot "out" +$script:Culture = "en-US" +$script:HelpPath = Join-Path $PSScriptRoot "help" . $PSScriptRoot\dobuild.ps1 -if ( ! ( Get-Module -ErrorAction SilentlyContinue PSPackageProject) ) { - Install-Module PSPackageProject -} - if ($Clean -and (Test-Path $OutDirectory)) { Remove-Item -Force -Recurse $OutDirectory -ErrorAction Stop -Verbose @@ -81,42 +58,52 @@ else if ($Build.IsPresent) { - $sb = (Get-Item Function:DoBuild).ScriptBlock - Invoke-PSPackageProjectBuild -BuildScript $sb -SkipPublish + DoBuild } if ($Publish.IsPresent) { - Invoke-PSPackageProjectPublish -Signed:$Signed.IsPresent + DoPackage } -if ( $TestInvokeDscResource.IsPresent ) { - $backupName = $null - try { - $configFolder = split-path $PROFILE - $configPath = Join-Path $configFolder -ChildPath powershell.config.json - if(Test-Path ~/.config/powershell/powershell.config.json) - { - $backupName = Join-Path $configFolder -ChildPath "powershell.config-((Get-Date).ToString('yyyyMMddHHmm')).json" - Copy-Item $configPath $backupName -force - } - - copy-Item $PSScriptRoot/assets/powershell.config.json $configPath - Invoke-PSPackageProjectTest -Type $TestType +if ($Test.IsPresent) { + if (-not (Get-Module -ListAvailable Pester)) { + Write-Verbose -Verbose "Pester module not found, installing" + Install-Module -Force -Name Pester -Scope CurrentUser -MinimumVersion 5.0.0 } - finally { - remove-item $configPath - if($backupName) - { - Copy-Item $backupName $configPath -force - } - } -} -if ( $Test.IsPresent ) { - Invoke-PSPackageProjectTest -Type $TestType + Import-Module Pester -MinimumVersion 5.0.0 + + $testPath = Join-Path $PSScriptRoot "test" + $config = [PesterConfiguration]::Default + $config.Run.Path = $testPath + $config.Run.Exit = $false + $config.TestResult.Enabled = $true + $config.TestResult.OutputPath = Join-Path $OutDirectory "testResults.xml" + $config.Output.Verbosity = "Detailed" + + Write-Verbose -Verbose "Running tests from: $testPath" + $result = Invoke-Pester -Configuration $config + + if ($result.FailedCount -gt 0) { + throw "$($result.FailedCount) test(s) failed" + } } if ($UpdateHelp.IsPresent) { - Add-PSPackageProjectCmdletHelp -ProjectRoot $ModuleRoot -ModuleName $ModuleName -Culture $Culture + # Build help using platyPS + $docsPath = Join-Path $PSScriptRoot "help" + $markdownDocsPath = Join-Path $docsPath "en-US" + $outputDocsPath = Join-Path $OutModule "en-US" + + if (-not (Get-Module -ListAvailable platyPS)) { + Write-Verbose -Verbose "platyPS module not found, installing" + Install-Module -Force -Name platyPS -Scope CurrentUser + } + + Import-Module platyPS -Verbose:$false + if (-not (Test-Path $outputDocsPath)) { + $null = New-Item -Type Directory -Path $outputDocsPath -Force + } + $null = New-ExternalHelp -Path $markdownDocsPath -OutputPath $outputDocsPath -Force } diff --git a/dobuild.ps1 b/dobuild.ps1 index 068dcf6..895c4c4 100644 --- a/dobuild.ps1 +++ b/dobuild.ps1 @@ -1,48 +1,27 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -##################################################### -# Do NOT edit anything outside the DoBuild function. -# You can define functions inside the scope of DoBuild. -##################################################### - -<# -.DESCRIPTION -Implement build and packaging of the package and place the output $OutDirectory/$ModuleName -#> function DoBuild { - Write-Verbose -Verbose -Message "Starting DoBuild" + Write-Verbose -Verbose -Message "Running DoBuild to layout module at: '${OutDirectory}/${ModuleName}'" + Copy-Item "${SrcPath}/*" "${OutDirectory}/${ModuleName}" -Recurse + Copy-Item -Recurse "${HelpPath}/${Culture}" "${OutDirectory}/${ModuleName}" +} - Write-Verbose -Verbose -Message "Copying module files to '${OutDirectory}/${ModuleName}'" - # copy psm1 and psd1 files - copy-item "${SrcPath}/*" "${OutDirectory}/${ModuleName}" -Recurse - # +function DoPackage +{ + try { + $repoName = [guid]::NewGuid().ToString() + $modulePath = Join-Path $OutDirectory $ModuleName + $null = Register-PSRepository -Name $repoName -InstallationPolicy Trusted -SourceLocation $OutDirectory - # copy help - Write-Verbose -Verbose -Message "Copying help files to '${OutDirectory}/${ModuleName}'" - copy-item -Recurse "${HelpPath}/${Culture}" "${OutDirectory}/${ModuleName}" + Write-Verbose -Verbose -Message "Publishing module from: '$modulePath'" + Publish-Module -Path $modulePath -Repository $repoName - if ( Test-Path "${SrcPath}/code" ) { - Write-Verbose -Verbose -Message "Building assembly and copying to '${OutDirectory}/${ModuleName}'" - # build code and place it in the staging location - try { - Push-Location "${SrcPath}/code" - $result = dotnet publish - copy-item "bin/Debug/netstandard2.0/publish/${ModuleName}.dll" "${OutDirectory}/${ModuleName}" - } - catch { - $result | ForEach-Object { Write-Warning $_ } - Write-Error "dotnet build failed" - } - finally { - Pop-Location - } + $nupkgPath = (Get-ChildItem -Path $OutDirectory -Filter "$ModuleName*.nupkg" | Select-Object -First 1).FullName + Write-Verbose -Verbose -Message "Created package: $nupkgPath" } - else { - Write-Verbose -Verbose -Message "No code to build in '${SrcPath}/code'" + finally { + Unregister-PSRepository -Name $repoName } - - ## Add build and packaging here - Write-Verbose -Verbose -Message "Ending DoBuild" } diff --git a/psdesiredstateconfiguration.nuspec b/psdesiredstateconfiguration.nuspec deleted file mode 100644 index ef4f122..0000000 --- a/psdesiredstateconfiguration.nuspec +++ /dev/null @@ -1,17 +0,0 @@ - - - - PSDesiredStateConfiguration - 2.0 - PSDesiredStateConfiguration - Microsoft - microsoft,powershell - false - Provides pre-built PSDesiredStateConfiguration module for PowerShell. - - © Microsoft Corporation. All rights reserved. - - - - - diff --git a/pspackageproject.json b/pspackageproject.json deleted file mode 100644 index b82b9c8..0000000 --- a/pspackageproject.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "HelpPath": "help", - "ModuleName": "PSDesiredStateConfiguration", - "BuildOutputPath": "out", - "SignedOutputPath": "signed", - "SourcePath": "src/PSDesiredStateConfiguration", - "TestPath": "test", - "Culture": "en-US" -} diff --git a/test/PSDesiredStateConfiguration.Tests.ps1 b/test/PSDesiredStateConfiguration.Tests.ps1 index 34a8ae5..177ed38 100644 --- a/test/PSDesiredStateConfiguration.Tests.ps1 +++ b/test/PSDesiredStateConfiguration.Tests.ps1 @@ -1,28 +1,35 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -Function Install-ModuleIfMissing { - param( - [parameter(Mandatory)] - [String] - $Name, - [version] - $MinimumVersion, - [switch] - $SkipPublisherCheck, - [switch] - $Force - ) - - $module = Get-Module -Name $Name -ListAvailable -ErrorAction Ignore | Sort-Object -Property Version -Descending | Select-Object -First 1 - - if (!$module -or $module.Version -lt $MinimumVersion) { - Write-Verbose "Installing module '$Name' ..." -Verbose - Install-Module -Name $Name -Force -SkipPublisherCheck:$SkipPublisherCheck.IsPresent + +BeforeDiscovery { + Function global:Install-ModuleIfMissing { + param( + [parameter(Mandatory)] + [String] + $Name, + [version] + $MinimumVersion, + [switch] + $SkipPublisherCheck, + [switch] + $Force + ) + + $module = Get-Module -Name $Name -ListAvailable -ErrorAction Ignore | Sort-Object -Property Version -Descending | Select-Object -First 1 + + if (!$module -or $module.Version -lt $MinimumVersion) { + Write-Verbose "Installing module '$Name' ..." -Verbose + Install-Module -Name $Name -Force -SkipPublisherCheck:$SkipPublisherCheck.IsPresent + } } -} -Function Test-IsInvokeDscResourceEnable { - return [ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource") + Function global:Test-IsInvokeDscResourceEnable { + # ExperimentalFeature is only available in PowerShell 7+ + if ($PSVersionTable.PSVersion.Major -lt 7) { + return $false + } + return [ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource") + } } Describe "Test PSDesiredStateConfiguration" -tags CI { @@ -31,10 +38,12 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { Function BeCommand { [CmdletBinding()] Param( - [object[]] $ActualValue, + $ActualValue, [string] $CommandName, [string] $ModuleName, - [switch]$Negate + [switch]$Negate, + [string]$Because, + $CallerSessionState ) $failure = if ($Negate) { diff --git a/test/configuration.Tests.ps1 b/test/configuration.Tests.ps1 index c423e8d..12faa4f 100644 --- a/test/configuration.Tests.ps1 +++ b/test/configuration.Tests.ps1 @@ -12,8 +12,8 @@ Describe "DSC MOF Compilation" -tags "CI" { } It "Should be able to compile a MOF using PSModule resource" { - if ($IsLinux) { - Set-ItResult -Pending -Because "https://github.com/PowerShell/PowerShellGet/pull/529" + if ($PSEdition -eq 'Core') { + Set-ItResult -Pending -Because "DSC MOF compilation requires Windows PowerShell" } Write-Verbose "DSC_HOME: ${env:DSC_HOME}" -verbose diff --git a/tools/installPSResources.ps1 b/tools/installPSResources.ps1 new file mode 100644 index 0000000..48ab81b --- /dev/null +++ b/tools/installPSResources.ps1 @@ -0,0 +1,24 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +param( + [ValidateSet("PSGallery", "CFS")] + [string]$PSRepository = "PSGallery" +) + +if ($PSRepository -eq "CFS" -and -not (Get-PSResourceRepository -Name CFS -ErrorAction SilentlyContinue)) { + Register-PSResourceRepository -Name CFS -Uri "https://pkgs.dev.azure.com/powershell/PowerShell/_packaging/PowerShellGalleryMirror/nuget/v3/index.json" +} + +# NOTE: Due to a bug in Install-PSResource with upstream feeds, we have to +# request an exact version. Otherwise, if a newer version is available in the +# upstream feed, it will fail to install any version at all. +Install-PSResource -Verbose -TrustRepository -RequiredResource @{ + platyPS = @{ + version = "0.14.2" + repository = $PSRepository + } + Pester = @{ + version = "5.7.1" + repository = $PSRepository + } +} diff --git a/tools/releaseBuild/FileCatalogSigning.xml b/tools/releaseBuild/FileCatalogSigning.xml deleted file mode 100644 index aecae22..0000000 --- a/tools/releaseBuild/FileCatalogSigning.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/tools/releaseBuild/generatePackgeSigning.ps1 b/tools/releaseBuild/generatePackgeSigning.ps1 deleted file mode 100644 index 61d5ea6..0000000 --- a/tools/releaseBuild/generatePackgeSigning.ps1 +++ /dev/null @@ -1,100 +0,0 @@ -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. -param( - [Parameter(Mandatory)] - [string] $Path, - [string[]] $AuthenticodeDualFiles, - [string[]] $AuthenticodeFiles, - [string[]] $NuPkgFiles, - [string[]] $MacDeveloperFiles, - [string[]] $LinuxFiles, - [Parameter(Mandatory)] - [string] $rootPath -) - -$resolvedRootPath = (Resolve-Path $rootPath).ProviderPath - -if ((!$AuthenticodeDualFiles -or $AuthenticodeDualFiles.Count -eq 0) -and - (!$AuthenticodeFiles -or $AuthenticodeFiles.Count -eq 0) -and - (!$NuPkgFiles -or $NuPkgFiles.Count -eq 0) -and - (!$MacDeveloperFiles -or $MacDeveloperFiles.Count -eq 0) -and - (!$LinuxFiles -or $LinuxFiles.Count -eq 0)) -{ - throw "At least one file must be specified" -} - -function New-Attribute -{ - param( - [Parameter(Mandatory)] - [string]$Name, - [Parameter(Mandatory)] - [object]$Value, - [Parameter(Mandatory)] - [System.Xml.XmlElement]$Element - ) - - $attribute = $signingXml.CreateAttribute($Name) - $attribute.Value = $value - $null = $fileElement.Attributes.Append($attribute) -} - -function New-FileElement -{ - param( - [Parameter(Mandatory)] - [string]$File, - [Parameter(Mandatory)] - [string]$SignType, - [Parameter(Mandatory)] - [System.Xml.XmlDocument]$XmlDoc, - [Parameter(Mandatory)] - [System.Xml.XmlElement]$Job - ) - - if(Test-Path -Path $file) - { - $name = Split-Path -Leaf -Path $File - $fileElement = $XmlDoc.CreateElement("file") - $src = $file.replace($resolvedRootPath,'__INPATHROOT__\') - $dest = $file.replace($resolvedRootPath,'__OUTPATHROOT__\') - New-Attribute -Name 'src' -value $src -Element $fileElement - New-Attribute -Name 'signType' -value $SignType -Element $fileElement - New-Attribute -Name 'dest' -value $dest -Element $fileElement - $null = $job.AppendChild($fileElement) - } - else - { - Write-Warning -Message "Skipping $SignType; $File because it does not exist" - } -} - -[xml]$signingXml = get-content (Join-Path -Path $PSScriptRoot -ChildPath 'packagesigning.xml') -$job = $signingXml.SignConfigXML.job - -foreach($file in $AuthenticodeDualFiles) -{ - New-FileElement -File $file -SignType 'AuthenticodeDual' -XmlDoc $signingXml -Job $job -} - -foreach($file in $AuthenticodeFiles) -{ - New-FileElement -File $file -SignType 'AuthenticodeFormer' -XmlDoc $signingXml -Job $job -} - -foreach($file in $NuPkgFiles) -{ - New-FileElement -File $file -SignType 'NuGet' -XmlDoc $signingXml -Job $job -} - -foreach ($file in $MacDeveloperFiles) { - New-FileElement -File $file -SignType 'MacDeveloper' -XmlDoc $signingXml -Job $job -} - -foreach ($file in $LinuxFiles) { - New-FileElement -File $file -SignType 'LinuxPack' -XmlDoc $signingXml -Job $job -} - -$null = new-item -Path $path -ItemType file -Force -$savePath = (Resolve-Path $Path).ProviderPath -$signingXml.Save($savePath) diff --git a/tools/releaseBuild/packagesigning.xml b/tools/releaseBuild/packagesigning.xml deleted file mode 100644 index 0c1bb06..0000000 --- a/tools/releaseBuild/packagesigning.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/tools/releaseBuild/signing.xml b/tools/releaseBuild/signing.xml deleted file mode 100644 index 1036937..0000000 --- a/tools/releaseBuild/signing.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - diff --git a/tools/terms/FileTypeSet.xml b/tools/terms/FileTypeSet.xml deleted file mode 100644 index 82f9f4d..0000000 --- a/tools/terms/FileTypeSet.xml +++ /dev/null @@ -1,379 +0,0 @@ - - - - - Pure Text Files - - .txt - .des - .pwd - .asm - .cmd - .ini - .poc - .pwt - .hpj - .sql - .inf - .log - .def - .url - .bat - .aspx - .idl - .sys - .resources - .strings - .md - .yml - .yaml - .spelling - .gitignore - .gitattributes - .gitmodules - .csv - .tsv - - - - CodeFiles - - .frm - .inc - .cpp - .cls - .c - .hpp - .vbs - .java - .cs - .cxx - .h - .jav - .bas - .hxx - .js - .pl - .rc - .vb - .json - .resjson - .fs - .fsi - .fsx - .m - .psm1 - .config - .ps1 - .psd1 - .cmake - .sh - .cshtml - .plist - .mof - .mc - - - - XML Files - - .xml - .hxa - .hxk - .hxl - .xsl - .hxc - .hxt - .hxm - .resx - .hxe - .hxf - .hxv - .acctb - .accfl - .xaml - .ttml - .ddue - .sln - .props - .ps1xml - .csproj - .xsd - .svg - .clixml - .nuspec - .cdxml - .manifest - - - - Microsoft Word Documents - - .doc - .dot - .wiz - - - - Microsoft Access Database Compatible - - .mdb - .mda - .mde - .mpd - .mdt - - - - Microsoft PowerPoint Presentation - - .ppt - .pot - .pps - - - - Microsoft Publisher Files - - .pub - - - - Microsoft Excel Workbooks - - .xls - .xlt - - - - Pure Binary Files - - .com - .bin - .tlb - .drv - .fon - .blg - .gif - .png - .icns - .ico - .bmp - .pfx - - - - Localization resource databases - - .edb - .lcl - .xlf - .xliff - - - - Microsoft Project Files - - .mpp - .mpt - - - - Microsoft Visio Files - - .vsd - .vdx - .vss - .vst - - - - Windows Installer databases - - .msi - .msm - - - - Zip Files - - .zip - .accdt - .axtr - - - - Cabinet / MS Compression Files - - .cab - - - - Table driven IME lexicons - - .mb - - - - IME ( IMD ) Files - - .imd - - - - TrueType Font Files - - .ttf - - - - Microsoft Outlook Mail Files - - .msg - .oft - - - - HTML Help 2.0 Files / InfoTech5.x Storage System Files - - .its - .hxh - .hxr - .hxw - .hxi - .hxs - .hxq - - - - Adobe Acrobat PDF Files - - .pdf - - - - HTML Files / Web Page - - .htm - .dtd - .hhk - .htw - .asp - .htc - .htx - .html - .hhc - .css - .stm - - - - Rich Text Files - - .rtf - - - - Windows 3.x Write Files - - .wri - - - - MHTML Files - - .eml - .nws - .mht - - - - Word 2007 Files - - .docx - .docm - .dotx - .dotm - - - - Excel 2007 Files - - .xlsx - .xlsm - .xltx - .xltm - .xlsb - .xlam - - - - Power Point 2007 Files - - .pptx - .pptm - .potx - .potm - .ppsx - .ppsm - .ppam - - - - Access 2007 Files - - .accdb - .accde - .accdr - - - - Win32/64-based executable (image) Files - - .exe - .dll - .ocx - .scr - .acm - .rll - .cpl - .mui - .ax - .ime - - - - HTML Help 1.0 Files - - .chm - - - - LocStudio lsg - - .lsg - - - - Microsoft Office OneNote Files - - .one - .onepkg - - - - Custom Parsers - - - - - Visio 2011 Files - - .vstx - .vsdx - .vssx - - - - - diff --git a/updateSigningXml.ps1 b/updateSigningXml.ps1 deleted file mode 100644 index 2e7289c..0000000 --- a/updateSigningXml.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -&$PSScriptRoot/build.ps1 -Build -Clean -Write-Verbose -Message "Updating signing.xml ..." -Verbose -$files = @(Get-ChildItem $PSScriptRoot/out/*.ps* -Recurse | Select-Object -ExpandProperty FullName) -&$PSScriptRoot/tools/releaseBuild/generatePackgeSigning.ps1 -AuthenticodeFiles $files -path $PSScriptRoot/tools/releaseBuild/signing.xml -rootPath $PSScriptRoot/out/ -Write-Verbose -Message "Done ..." -Verbose -# Make sure the file ends with an empty line -Add-Content -value '' -Path $PSScriptRoot/tools/releaseBuild/signing.xml From 72cfe4aaeea97dae13bc870366864e9b7397f59c Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Thu, 5 Feb 2026 10:55:56 -0800 Subject: [PATCH 2/3] Remove deprecated experimental feature code --- assets/powershell.config.json | 9 --- test/PSDesiredStateConfiguration.Tests.ps1 | 82 +++++----------------- 2 files changed, 19 insertions(+), 72 deletions(-) delete mode 100644 assets/powershell.config.json diff --git a/assets/powershell.config.json b/assets/powershell.config.json deleted file mode 100644 index 76bc675..0000000 --- a/assets/powershell.config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ExperimentalFeatures": [ - "PSCommandNotFoundSuggestion", - "PSForEachObjectParallel", - "PSImplicitRemotingBatching", - "Microsoft.PowerShell.Utility.PSDebugRunspaceWithBreakpoints", - "PSDesiredStateConfiguration.InvokeDscResource" - ] -} diff --git a/test/PSDesiredStateConfiguration.Tests.ps1 b/test/PSDesiredStateConfiguration.Tests.ps1 index 177ed38..3cc1c74 100644 --- a/test/PSDesiredStateConfiguration.Tests.ps1 +++ b/test/PSDesiredStateConfiguration.Tests.ps1 @@ -22,14 +22,6 @@ BeforeDiscovery { Install-Module -Name $Name -Force -SkipPublisherCheck:$SkipPublisherCheck.IsPresent } } - - Function global:Test-IsInvokeDscResourceEnable { - # ExperimentalFeature is only available in PowerShell 7+ - if ($PSVersionTable.PSVersion.Major -lt 7) { - return $false - } - return [ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource") - } } Describe "Test PSDesiredStateConfiguration" -tags CI { @@ -83,7 +75,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $commands | Should -HaveCommand -CommandName 'Get-DscResource' -ModuleName PSDesiredStateConfiguration } - It "The module should have the Invoke-DscResource Command" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + It "The module should have the Invoke-DscResource Command" { $commands | Should -HaveCommand -CommandName 'Invoke-DscResource' -ModuleName PSDesiredStateConfiguration } } @@ -129,13 +121,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resource = Get-DscResource -Name $name $resource | Should -Not -BeNullOrEmpty $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - + $resource.ImplementationDetail | Should -BeNullOrEmpty } it "should be able to get from - " -TestCases $testCases { @@ -152,12 +138,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resource = Get-DscResource -Name $Name -Module $ModuleName $resource | Should -Not -BeNullOrEmpty $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } + $resource.ImplementationDetail | Should -BeNullOrEmpty } } @@ -230,13 +211,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resources | Should -Not -BeNullOrEmpty foreach ($resource in $resource) { $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ScriptBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } - + $resource.ImplementationDetail | Should -Be 'ScriptBased' } } @@ -255,12 +230,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resources | Should -Not -BeNullOrEmpty foreach ($resource in $resource) { $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ScriptBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } + $resource.ImplementationDetail | Should -Be 'ScriptBased' } } @@ -311,12 +281,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resource = Get-DscResource -Name $Name -Module $ModuleName $resource | Should -Not -BeNullOrEmpty $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ClassBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } + $resource.ImplementationDetail | Should -Be 'ClassBased' } it "should be able to get class resource - - " -TestCases $classTestCases { @@ -332,12 +297,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resource = Get-DscResource -Name $Name $resource | Should -Not -BeNullOrEmpty $resource.Name | Should -Be $Name - if (Test-IsInvokeDscResourceEnable) { - $resource.ImplementationDetail | Should -Be 'ClassBased' - } - else { - $resource.ImplementationDetail | Should -BeNullOrEmpty - } + $resource.ImplementationDetail | Should -Be 'ClassBased' } } Context "Invoke-DscResource" { @@ -382,7 +342,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $psGetModuleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() } } - it "Set method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Set method should work" { if (!$IsLinux) { $result = Invoke-DscResource -Name PSModule -ModuleName $psGetModuleSpecification -Method set -Property @{ Name = 'PsDscResources' @@ -398,7 +358,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $module = Get-module PsDscResources -ListAvailable $module | Should -Not -BeNullOrEmpty -Because "Resource should have installed module" } - it 'Set method should return RebootRequired= when $global:DSCMachineStatus = ' -Skip:(!(Test-IsInvokeDscResourceEnable)) -TestCases $dscMachineStatusCases { + it 'Set method should return RebootRequired= when $global:DSCMachineStatus = ' -TestCases $dscMachineStatusCases { param( $value, $ExpectedResult @@ -411,25 +371,25 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $result.RebootRequired | Should -BeExactly $expectedResult } - it "Test method should return false" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Test method should return false" { $result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = { return } } $result | Should -Not -BeNullOrEmpty $result.InDesiredState | Should -BeFalse -Because "Test method return false" } - it "Test method should return true" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Test method should return true" { $result = Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Test -Property @{TestScript = { Write-Verbose 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } $result | Should -BeTrue -Because "Test method return true" } - it "Test method should return true with moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Test method should return true with moduleSpecification" { $module = get-module PsDscResources -ListAvailable $moduleSpecification = @{ModuleName = $module.Name; ModuleVersion = $module.Version.ToString() } $result = Invoke-DscResource -Name Script -ModuleName $moduleSpecification -Method Test -Property @{TestScript = { Write-Verbose 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } $result | Should -BeTrue -Because "Test method return true" } - it "Invalid moduleSpecification" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Invalid moduleSpecification" { Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" $moduleSpecification = @{ModuleName = 'PsDscResources'; ModuleVersion = '99.99.99.993' } { @@ -438,11 +398,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { Should -Throw -ErrorId 'InvalidResourceSpecification,Invoke-DscResource' -ExpectedMessage 'Invalid Resource Name ''Script'' or module specification.' } - it "Test an embedded DSC resource" { - if (!(Test-IsInvokeDscResourceEnable)) { - Set-ItResult -Skipped -Because "Feature not enabled" - } - + it "Test an embedded DSC resource" { $resourceName="TestRes" $moduleName="TestEmbeddedDSCResource" $embObj = @(New-Object -TypeName psobject -Property @{embclassprop="property1"}) @@ -471,7 +427,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $result.RebootRequired | Should -BeFalse } - it "Using PsDscRunAsCredential should say not supported" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Using PsDscRunAsCredential should say not supported" { { Invoke-DscResource -Name Script -ModuleName PSDscResources -Method Set -Property @{TestScript = { Write-Output 'test'; return $false }; GetScript = { return @{ } }; SetScript = {return}; PsDscRunAsCredential='natoheu'} -ErrorAction Stop } | @@ -479,7 +435,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { } # waiting on Get-DscResource to be fixed - it "Invalid module name" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Invalid module name" { Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" { Invoke-DscResource -Name Script -ModuleName santoheusnaasonteuhsantoheu -Method Test -Property @{TestScript = { Write-Host 'test'; return $true }; GetScript = { return @{ } }; SetScript = { return } } -ErrorAction Stop @@ -487,7 +443,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound' } - it "Invalid resource name" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Invalid resource name" { if ($IsWindows) { Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/17" } @@ -498,7 +454,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { Should -Throw -ErrorId 'Microsoft.PowerShell.Commands.WriteErrorException,CheckResourceFound' } - it "Get method should work" -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it "Get method should work" { if ($IsLinux) { Set-ItResult -Pending -Because "https://github.com/PowerShell/PSDesiredStateConfiguration/issues/12 and https://github.com/PowerShell/PowerShellGet/pull/529" } @@ -539,7 +495,7 @@ Describe "Test PSDesiredStateConfiguration" -tags CI { $resolvedXmlPath = (Resolve-Path -Path $testXmlPath).ProviderPath } - it 'Set method should work' -Skip:(!(Test-IsInvokeDscResourceEnable)) { + it 'Set method should work' { param( $value, $ExpectedResult From 7267b4c00714f4aff0506b3e55e17a860e6fe6b0 Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Thu, 5 Feb 2026 10:57:12 -0800 Subject: [PATCH 3/3] Install fixed Pester version --- .github/workflows/ci-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-test.yml b/.github/workflows/ci-test.yml index 0f94ca0..a1d5de7 100644 --- a/.github/workflows/ci-test.yml +++ b/.github/workflows/ci-test.yml @@ -28,7 +28,7 @@ jobs: - name: Test Windows PowerShell run: | - Install-Module Pester -Scope CurrentUser -Force -SkipPublisherCheck + ./tools/installPSResources.ps1 ./build.ps1 -Test shell: powershell