Skip to content

Commit ff881f4

Browse files
DSC v3 resource for PSResourceGet (#1852)
1 parent e256d8b commit ff881f4

21 files changed

Lines changed: 1886 additions & 3 deletions

.ci/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ pr:
1010
include:
1111
- master
1212

13+
parameters:
14+
- name: DSCVersion
15+
default: '3.2.0-rc.1'
16+
type: string
17+
1318
resources:
1419
repositories:
1520
- repository: ComplianceRepo
@@ -122,29 +127,34 @@ stages:
122127
jobName: TestPkgWin
123128
displayName: PowerShell Core on Windows
124129
imageName: windows-latest
130+
DSCVersion: ${{ parameters.DSCVersion }}
125131

126132
- template: test.yml
127133
parameters:
128134
jobName: TestPkgWinPS
129135
displayName: Windows PowerShell on Windows
130136
imageName: windows-latest
131137
powershellExecutable: powershell
138+
DSCVersion: ${{ parameters.DSCVersion }}
132139

133140
- template: test.yml
134141
parameters:
135142
jobName: TestPkgUbuntu
136143
displayName: PowerShell Core on Ubuntu
137144
imageName: ubuntu-latest
145+
DSCVersion: ${{ parameters.DSCVersion }}
138146

139147
- template: test.yml
140148
parameters:
141149
jobName: TestPkgWinMacOS
142150
displayName: PowerShell Core on macOS
143151
imageName: macOS-latest
152+
DSCVersion: ${{ parameters.DSCVersion }}
144153

145154
- template: test.yml
146155
parameters:
147156
jobName: TestPkgWinAzAuth
148157
displayName: AzAuth PowerShell Core on Windows
149158
imageName: windows-latest
150159
useAzAuth: true
160+
DSCVersion: ${{ parameters.DSCVersion }}

.ci/test.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ parameters:
55
powershellExecutable: pwsh
66
buildDirectory: '.'
77
useAzAuth: false
8+
DSCVersion: '3.2.0-rc.1'
89

910
jobs:
1011
- job: ${{ parameters.jobName }}
@@ -95,6 +96,56 @@ jobs:
9596
displayName: 'Setup Azure Artifacts Credential Provider secret'
9697
condition: eq(${{ parameters.useAzAuth }}, false)
9798

99+
- pwsh: |
100+
$version = '${{ parameters.DSCVersion }}'
101+
$packageName = "DSC-$version"
102+
$ext = 'tar.gz'
103+
$executableName = 'dsc'
104+
$executableExt = if ($IsWindows) { '.exe' } else { '' }
105+
106+
$uri = if ($IsWindows) {
107+
$ext = 'zip'
108+
"https://github.com/PowerShell/DSC/releases/download/v$version/DSC-$version-x86_64-pc-windows-msvc.zip"
109+
} elseif ($IsLinux) {
110+
"https://github.com/PowerShell/DSC/releases/download/v$version/DSC-$version-x86_64-linux.tar.gz"
111+
}
112+
elseif ($IsMacOS) {
113+
"https://github.com/PowerShell/DSC/releases/download/v$version/DSC-$version-x86_64-apple-darwin.tar.gz"
114+
115+
}
116+
else {
117+
throw "Unsupported OS platform"
118+
}
119+
120+
$destPath = Join-Path -Path $env:AGENT_TEMPDIRECTORY -ChildPath "$packageName.$ext"
121+
122+
Write-Verbose -Verbose "Downloading DSC v3 from $uri to $destPath"
123+
124+
Invoke-WebRequest -Uri $uri -OutFile $destPath
125+
126+
if ($IsWindows) {
127+
Expand-Archive -Path $destPath -DestinationPath $env:AGENT_TEMPDIRECTORY -Force -Verbose
128+
}
129+
else {
130+
tar -xzf $destPath -C $env:AGENT_TEMPDIRECTORY
131+
}
132+
133+
$executableFileName = $executableName + $executableExt
134+
135+
$executable = Get-ChildItem -Path $env:AGENT_TEMPDIRECTORY -File -Recurse -Verbose | Where-Object { $_.Name -eq $executableFileName } | Select-Object -First 1
136+
137+
if (-not $executable) {
138+
throw "Could not find dsc executable in the downloaded package"
139+
}
140+
141+
$dscRoot = Split-Path -Path $executable.FullName -Parent
142+
143+
$vstsCommandString = "vso[task.setvariable variable=DSC_ROOT]$dscRoot"
144+
Write-Host "sending " + $vstsCommandString
145+
Write-Host "##$vstsCommandString"
146+
147+
displayName: 'Install latest DSC v3'
148+
98149
- pwsh: |
99150
Get-ChildItem -Path env: | Out-String -width 9999 -Stream | Write-Verbose -Verbose
100151
displayName: Capture environment

doBuild.ps1

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ function DoBuild
4747
Write-Verbose -Verbose -Message "Copying PSResourceRepository.admx to '$BuildOutPath'"
4848
Copy-Item -Path "${SrcPath}/PSResourceRepository.admx" -Dest "$BuildOutPath" -Force
4949

50+
Write-Verbose -Verbose -Message "Copying psresourceget.ps1 to '$BuildOutPath'"
51+
Copy-Item -Path "${SrcPath}/dsc/psresourceget.ps1" -Dest "$BuildOutPath" -Force
52+
53+
Write-Verbose -Verbose -Message "Copying resource manifests to '$BuildOutPath'"
54+
Copy-Item -Path "${SrcPath}/dsc/*.resource.json" -Dest "$BuildOutPath" -Force
55+
5056
# Build and place binaries
5157
if ( Test-Path "${SrcPath}/code" ) {
5258
Write-Verbose -Verbose -Message "Building assembly and copying to '$BuildOutPath'"

0 commit comments

Comments
 (0)