Skip to content

Commit 2568cc1

Browse files
PSResources get
1 parent aca1d97 commit 2568cc1

2 files changed

Lines changed: 20 additions & 12 deletions

File tree

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'"

src/dsc/psresourceget.ps1

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using namespace NuGet.Versioning
1+
## Copyright (c) Microsoft Corporation. All rights reserved.
2+
## Licensed under the MIT License.
23

34
[CmdletBinding()]
45
param(
@@ -33,8 +34,6 @@ trap {
3334

3435
function GetAllPSResources {
3536
$resources = Get-PSResource
36-
37-
3837
}
3938

4039
function GetOperation {
@@ -73,6 +72,8 @@ function GetOperation {
7372
$resourcesExist = @()
7473
$resourcesMissing = @()
7574

75+
Add-Type -AssemblyName "$PSScriptRoot/dependencies/NuGet.Versioning.dll"
76+
7677
foreach ($resource in $allPSResources) {
7778
foreach ($inputResource in $inputObj.resources) {
7879
if ($resource.Name -eq $inputResource.Name) {
@@ -81,23 +82,24 @@ function GetOperation {
8182
try {
8283
$versionRange = [NuGet.Versioning.VersionRange]::Parse($inputResource.Version)
8384
$resourceVersion = [NuGet.Versioning.NuGetVersion]::Parse($resource.Version.ToString())
84-
if (-not $versionRange.Satisfies($resourceVersion)) {
85-
continue
85+
if ($versionRange.Satisfies($resourceVersion)) {
86+
$resourcesExist += $resource
8687
}
8788
else {
88-
$resourcesExist += $resource
89-
continue
89+
$resourcesMissing += $inputResource
9090
}
91-
} catch {
91+
}
92+
catch {
9293
# Fallback: simple string comparison (not full NuGet range support)
93-
if ($resource.Version.ToString() -ne $inputObj.resources.Version) {
94-
continue
94+
if ($resource.Version.ToString() -eq $inputResource.Version) {
95+
$resourcesExist += $resource
96+
}
97+
else {
98+
$resourcesMissing += $inputResource
9599
}
96100
}
97101
}
98102
}
99-
100-
$resourcesMissing += $resource
101103
}
102104
}
103105

0 commit comments

Comments
 (0)