mirror of
https://github.com/PowerShell/PSDesiredStateConfiguration
synced 2026-06-21 13:45:25 +00:00
Compare commits
18 Commits
CI-Updates
..
fix73
| Author | SHA1 | Date | |
|---|---|---|---|
| f9956c34de | |||
| 727085ecaa | |||
| a935614790 | |||
| 7c063aed9d | |||
| b83ba2ccc0 | |||
| 316773dfe6 | |||
| 11b3bd0fdb | |||
| 4af8841d74 | |||
| ad361bfe4b | |||
| 08b5f4de0e | |||
| f142525bc7 | |||
| a9182cf60e | |||
| 68cfed18c9 | |||
| 3ae4b6afda | |||
| 4777a3ed77 | |||
| 85eeda51a6 | |||
| 70dad1f41e | |||
| 1cb7076792 |
+136
-10
@@ -20,19 +20,145 @@ resources:
|
||||
stages:
|
||||
- stage: Build
|
||||
displayName: Build PSDesiredStateConfiguration module
|
||||
pool:
|
||||
name: Package ES CodeHub Lab E
|
||||
jobs:
|
||||
- job: BuildPkg
|
||||
displayName: Build Package
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
variables:
|
||||
- group: ESRP
|
||||
steps:
|
||||
- template: templates/ci-build.yml
|
||||
- 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: |
|
||||
Write-Verbose "BUILD_OUTPUT_PATH- $env:BUILD_OUTPUT_PATH" -Verbose
|
||||
Write-Verbose "SIGNED_OUTPUT_PATH- $env:SIGNED_OUTPUT_PATH" -Verbose
|
||||
Copy-Item $env:BUILD_OUTPUT_PATH $env:SIGNED_OUTPUT_PATH -Recurse -Force
|
||||
displayName: Build Signing Placeholder
|
||||
Get-ChildItem -Path env:
|
||||
displayName: Capture environment for build
|
||||
condition: succeededOrFailed()
|
||||
|
||||
- pwsh: |
|
||||
$(Build.SourcesDirectory)/build.ps1 -Publish -Signed
|
||||
displayName: Publish
|
||||
timeoutInMinutes: 10
|
||||
$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.
|
||||
|
||||
@@ -9,11 +9,19 @@ resources:
|
||||
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: Package ES CodeHub Lab E
|
||||
name: PowerShell1ES
|
||||
demands:
|
||||
- ImageOverride -equals PSMMS2019-Secure
|
||||
jobs:
|
||||
- job: BuildPkg
|
||||
displayName: Build Package
|
||||
@@ -23,14 +31,14 @@ stages:
|
||||
- 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
|
||||
./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 5.9.1'
|
||||
displayName: 'Install NuGet'
|
||||
inputs:
|
||||
checkLatest: false
|
||||
version: 5.9.1
|
||||
@@ -105,6 +113,13 @@ stages:
|
||||
# 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"
|
||||
@@ -131,7 +146,9 @@ stages:
|
||||
jobs:
|
||||
- job: Compliance_Job
|
||||
pool:
|
||||
name: Package ES CodeHub Lab E
|
||||
name: PowerShell1ES
|
||||
demands:
|
||||
- ImageOverride -equals PSMMS2019-Secure
|
||||
steps:
|
||||
- checkout: self
|
||||
- checkout: ComplianceRepo
|
||||
@@ -164,7 +181,9 @@ stages:
|
||||
- deployment: DeployPowerShellGallery
|
||||
displayName: Deploy nupkg to PowerShell Gallery
|
||||
pool:
|
||||
vmImage: windows-latest
|
||||
name: PowerShell1ES
|
||||
demands:
|
||||
- ImageOverride -equals PSMMS2019-Secure
|
||||
environment: 'PSDesiredStateConfiguration-ReleaseApproval'
|
||||
strategy:
|
||||
runOnce:
|
||||
@@ -173,7 +192,7 @@ stages:
|
||||
- download: current
|
||||
artifact: 'nupkg'
|
||||
- task: NuGetToolInstaller@1
|
||||
displayName: 'Install NuGet 5.9.1'
|
||||
displayName: 'Install NuGet'
|
||||
inputs:
|
||||
checkLatest: false
|
||||
version: 5.9.1
|
||||
@@ -183,4 +202,4 @@ stages:
|
||||
command: push
|
||||
packagesToPush: '$(Pipeline.Workspace)\nupkg\PSDesiredStateConfiguration.*.nupkg'
|
||||
nuGetFeedType: external
|
||||
publishFeedCredentials: 'PowerShellGallery'
|
||||
publishFeedCredentials: 'PowerShellGallery'
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# Changelogs
|
||||
|
||||
* [v2 changelog](v2.md)
|
||||
@@ -0,0 +1,23 @@
|
||||
# v2 Changelog
|
||||
|
||||
## [v2.0.7]
|
||||
|
||||
### Main changes
|
||||
|
||||
- Fixed Invoke-DscResource error when a class-based resource module path contains a space.
|
||||
|
||||
[v2.0.7]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.7
|
||||
|
||||
## [v2.0.6]
|
||||
|
||||
### Main changes
|
||||
|
||||
- Fixed `PathSeparator` bug in Get-DSCResourceModules.
|
||||
- Changed `PSDesiredStateConfiguration.InvokeDscResource` from experimental to permanently enabled feature.
|
||||
- Changed `ErrorAction` to `Ignore` so that the error doesn't show up in `$Error`.
|
||||
- Removed duplicate result resources from `Get-DSCResourcesModules`.
|
||||
- Add `ImplementationDetail` member to results only when the member does not already exist.
|
||||
- Updated v2 Release pipeline with latest Compliance requirements.
|
||||
- Added SBOM generation that is now released with v2 module.
|
||||
|
||||
[v2.0.6]: https://www.powershellgallery.com/packages/PSDesiredStateConfiguration/2.0.6
|
||||
@@ -9,7 +9,7 @@
|
||||
RootModule = 'PSDesiredStateConfiguration.psm1'
|
||||
|
||||
# Version number of this module.
|
||||
moduleVersion = '2.0.5'
|
||||
moduleVersion = '2.0.7'
|
||||
|
||||
# Supported PSEditions
|
||||
CompatiblePSEditions = @('Core')
|
||||
@@ -100,13 +100,11 @@ HelpInfoURI = 'https://go.microsoft.com/fwlink/?linkid=2113535'
|
||||
|
||||
PrivateData = @{
|
||||
PSData = @{
|
||||
ExperimentalFeatures = @(
|
||||
@{
|
||||
Name = 'PSDesiredStateConfiguration.InvokeDscResource'
|
||||
Description = "Enables the Invoke-DscResource cmdlet and related features."
|
||||
}
|
||||
)
|
||||
}
|
||||
Tags = @('PSDesiredStateConfiguration',
|
||||
'Linux',
|
||||
'Mac',
|
||||
'Windows')
|
||||
ProjectUri = 'https://github.com/PowerShell/PSDesiredStateConfiguration'
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ data LocalizedData
|
||||
Set-StrictMode -Off
|
||||
|
||||
# In case localized resource is not available we revert back to English as defined in LocalizedData section so ignore the error instead of showing it to user.
|
||||
Import-LocalizedData -BindingVariable LocalizedData -FileName PSDesiredStateConfiguration.Resource.psd1 -ErrorAction SilentlyContinue
|
||||
Import-LocalizedData -BindingVariable LocalizedData -FileName PSDesiredStateConfiguration.Resource.psd1 -ErrorAction Ignore
|
||||
|
||||
Import-Module $PSScriptRoot/helpers/DscResourceInfo.psm1
|
||||
|
||||
@@ -3679,7 +3679,7 @@ function New-DscChecksum
|
||||
}
|
||||
|
||||
# If the Force parameter was not specified and the hash file already exists for the current file, log this, and skip this file
|
||||
if (!$Force -and (Get-Item -Path $fileOutpath -ErrorAction SilentlyContinue))
|
||||
if (!$Force -and (Get-Item -Path $fileOutpath -ErrorAction Ignore))
|
||||
{
|
||||
Write-Log -Message ($LocalizedData.CheckSumFileExists -f $fileOutpath)
|
||||
continue
|
||||
@@ -4047,7 +4047,7 @@ function Get-DscResource
|
||||
|
||||
End
|
||||
{
|
||||
$Resources = $Resources | Sort-Object -Property Module, Name
|
||||
$Resources = $Resources | Sort-Object -Property Module, Name -Unique
|
||||
foreach ($resource in $Resources)
|
||||
{
|
||||
# return formatted string if required
|
||||
@@ -4140,7 +4140,8 @@ function GetResourceFromKeyword
|
||||
$schemaToProcess = $classesFromSchema | ForEach-Object -Process {
|
||||
if(($_.CimSystemProperties.ClassName -ieq $keyword.ResourceName) -and ($_.CimSuperClassName -ieq 'OMI_BaseResource'))
|
||||
{
|
||||
if ([ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource"))
|
||||
$member = Get-Member -InputObject $_ -MemberType NoteProperty -Name 'ImplementationDetail'
|
||||
if ($null -eq $member)
|
||||
{
|
||||
$_ | Add-Member -MemberType NoteProperty -Name 'ImplementationDetail' -Value $implementationDetail -PassThru
|
||||
}
|
||||
@@ -4210,10 +4211,8 @@ function GetResourceFromKeyword
|
||||
Ascending = $true
|
||||
}
|
||||
$resource.UpdateProperties($updatedProperties)
|
||||
if ([ExperimentalFeature]::IsEnabled("PSDesiredStateConfiguration.InvokeDscResource"))
|
||||
{
|
||||
$resource | Add-Member -MemberType NoteProperty -Name 'ImplementationDetail' -Value $implementationDetail
|
||||
}
|
||||
|
||||
$resource | Add-Member -MemberType NoteProperty -Name 'ImplementationDetail' -Value $implementationDetail
|
||||
|
||||
return $resource
|
||||
}
|
||||
@@ -4647,7 +4646,6 @@ Export-ModuleMember -Function Get-DscResource, Configuration
|
||||
|
||||
function Invoke-DscResource
|
||||
{
|
||||
[Experimental("PSDesiredStateConfiguration.InvokeDscResource", "Show")]
|
||||
[CmdletBinding(HelpUri = '')]
|
||||
param (
|
||||
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true, Mandatory)]
|
||||
@@ -4751,7 +4749,7 @@ function Invoke-DscClassBasedResource
|
||||
$iss = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault2()
|
||||
$powershell = [PowerShell]::Create($iss)
|
||||
$script = @"
|
||||
using module $path
|
||||
using module "$path"
|
||||
|
||||
Write-Host -Message ([$type]::new | out-string)
|
||||
return [$type]::new()
|
||||
|
||||
Reference in New Issue
Block a user