Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/actions/spelling/patterns.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ GetRestAPIBaseUri\(".*"\) == L".*"

# Sample store product id for App Installer
9nblggh4nns1
9NVTPZWRC6KQ

# Automatically suggested patterns

Expand Down
6 changes: 4 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,11 @@ jobs:
displayName: Clean up Sysinternals PsTools
condition: succeededOrFailed()

# Install DSC v3 preview until the DSC v3 processor handles that on its own
# Install DSC v3 until the DSC v3 processor handles that on its own
- powershell: |
Install-WinGetPackage -Id Microsoft.DSC.Preview -Source winget
$installResult = Install-WinGetPackage -Id Microsoft.DSC.Preview -Source winget -InstallerType Msix -Version 3.1.1
$installResult | Format-List
if ($installResult.ExtendedErrorCode) { throw $installResult.ExtendedErrorCode }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: do we still need these debug related scripts?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is what is installing DSC for the pipeline currently.

I'm still considering how best to have the configuration code paths handle acquiring DSC themselves.

displayName: Install DSC v3
condition: succeededOrFailed()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Microsoft.Management.Configuration.Processor.DSCv3.Helpers
{
using System;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Management.Configuration.Processor.DSCv3.Model;

Expand Down Expand Up @@ -109,28 +109,18 @@ public IDSCv3 DSCv3
/// <returns>The full path to the dsc.exe executable, or null if not found.</returns>
public static string? FindDscExecutablePath()
{
// To start, only attempt to find the package and launch it via the app execution fallback handler.
// In the future, discover it through %PATH% searching, but probably don't allow that from an elevated process.
// To start, only attempt to find the package and launch it via app execution alias.
// In the future, consider discovering it through %PATH% searching, but probably don't allow that from an elevated process.
// That probably means creating another read property for finding the secure path.
Windows.Management.Deployment.PackageManager packageManager = new Windows.Management.Deployment.PackageManager();

// Until there is a non-preview of this package, use the preview version.
var packages = packageManager.FindPackagesForUser(null, "Microsoft.DesiredStateConfiguration-Preview_8wekyb3d8bbwe");

if (packages == null)
{
return null;
}

string packageInstallLocation = packages.First().InstalledLocation.Path;
string result = Path.Combine(packageInstallLocation, DscExecutableFileName);

if (!Path.Exists(result))
#if !AICLI_DISABLE_TEST_HOOKS
string? result = GetDscExecutablePathForPackage("Microsoft.DesiredStateConfiguration-Preview_8wekyb3d8bbwe");
if (result != null)
{
return null;
return result;
}
#endif

return result;
return GetDscExecutablePathForPackage("Microsoft.DesiredStateConfiguration_8wekyb3d8bbwe");
}

/// <summary>
Expand Down Expand Up @@ -166,5 +156,18 @@ public override string ToString()

return sb.ToString();
}

private static string? GetDscExecutablePathForPackage(string packageFamilyName)
{
string localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
string result = Path.Combine(localAppData, "Microsoft\\WindowsApps", packageFamilyName, DscExecutableFileName);

if (!Path.Exists(result))
{
return null;
}

return result;
}
}
}
Loading