Skip to content

Commit 92daa5f

Browse files
authored
Support official DSC v3 release (microsoft#5313)
## Change Install the specific, MSIX version from the winget-pkgs in the pipeline. (Store installs don't work on Server 2022) In the processor, find `dsc.exe` by the alias location. Support the preview version for test builds (anything from winget-cli).
1 parent 6ec90f2 commit 92daa5f

File tree

3 files changed

+27
-21
lines changed

3 files changed

+27
-21
lines changed

.github/actions/spelling/patterns.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ GetRestAPIBaseUri\(".*"\) == L".*"
3434

3535
# Sample store product id for App Installer
3636
9nblggh4nns1
37+
9NVTPZWRC6KQ
3738

3839
# Automatically suggested patterns
3940

azure-pipelines.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,9 +377,11 @@ jobs:
377377
displayName: Clean up Sysinternals PsTools
378378
condition: succeededOrFailed()
379379
380-
# Install DSC v3 preview until the DSC v3 processor handles that on its own
380+
# Install DSC v3 until the DSC v3 processor handles that on its own
381381
- powershell: |
382-
Install-WinGetPackage -Id Microsoft.DSC.Preview -Source winget
382+
$installResult = Install-WinGetPackage -Id Microsoft.DSC.Preview -Source winget -InstallerType Msix -Version 3.1.1
383+
$installResult | Format-List
384+
if ($installResult.ExtendedErrorCode) { throw $installResult.ExtendedErrorCode }
383385
displayName: Install DSC v3
384386
condition: succeededOrFailed()
385387

src/Microsoft.Management.Configuration.Processor/DSCv3/Helpers/ProcessorSettings.cs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
namespace Microsoft.Management.Configuration.Processor.DSCv3.Helpers
88
{
9+
using System;
910
using System.IO;
10-
using System.Linq;
1111
using System.Text;
1212
using Microsoft.Management.Configuration.Processor.DSCv3.Model;
1313

@@ -109,28 +109,18 @@ public IDSCv3 DSCv3
109109
/// <returns>The full path to the dsc.exe executable, or null if not found.</returns>
110110
public static string? FindDscExecutablePath()
111111
{
112-
// To start, only attempt to find the package and launch it via the app execution fallback handler.
113-
// In the future, discover it through %PATH% searching, but probably don't allow that from an elevated process.
112+
// To start, only attempt to find the package and launch it via app execution alias.
113+
// In the future, consider discovering it through %PATH% searching, but probably don't allow that from an elevated process.
114114
// That probably means creating another read property for finding the secure path.
115-
Windows.Management.Deployment.PackageManager packageManager = new Windows.Management.Deployment.PackageManager();
116-
117-
// Until there is a non-preview of this package, use the preview version.
118-
var packages = packageManager.FindPackagesForUser(null, "Microsoft.DesiredStateConfiguration-Preview_8wekyb3d8bbwe");
119-
120-
if (packages == null)
121-
{
122-
return null;
123-
}
124-
125-
string packageInstallLocation = packages.First().InstalledLocation.Path;
126-
string result = Path.Combine(packageInstallLocation, DscExecutableFileName);
127-
128-
if (!Path.Exists(result))
115+
#if !AICLI_DISABLE_TEST_HOOKS
116+
string? result = GetDscExecutablePathForPackage("Microsoft.DesiredStateConfiguration-Preview_8wekyb3d8bbwe");
117+
if (result != null)
129118
{
130-
return null;
119+
return result;
131120
}
121+
#endif
132122

133-
return result;
123+
return GetDscExecutablePathForPackage("Microsoft.DesiredStateConfiguration_8wekyb3d8bbwe");
134124
}
135125

136126
/// <summary>
@@ -166,5 +156,18 @@ public override string ToString()
166156

167157
return sb.ToString();
168158
}
159+
160+
private static string? GetDscExecutablePathForPackage(string packageFamilyName)
161+
{
162+
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
163+
string result = Path.Combine(localAppData, "Microsoft\\WindowsApps", packageFamilyName, DscExecutableFileName);
164+
165+
if (!Path.Exists(result))
166+
{
167+
return null;
168+
}
169+
170+
return result;
171+
}
169172
}
170173
}

0 commit comments

Comments
 (0)