winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit fa48fd8b933d2fb71bb20a21ef2952ff1b10f5a2
parent ced7e0ad723fb6d34e1360b868f495f66f4c8035
Author: Ruben Guerrero <rubengu@microsoft.com>
Date:   Mon, 15 May 2023 14:11:37 -0700

Update PSDesiredStateConfiguration module min version (#3251)

Update to PSDesiredStateConfiguration 2.0.7.

With this change, winget configure will download the 2.0.7 automatically.

This version contains a fix where Invoke-DSCResource failed when a class based resource is going to be invoke and it lives in a path with spaces on it. Bug details
Diffstat:
Msrc/Microsoft.Management.Configuration.Processor/Constants/PowerShellConstants.cs | 2+-
Msrc/Microsoft.Management.Configuration.Processor/DscModules/DscModuleV2.cs | 2+-
Msrc/Microsoft.Management.Configuration.UnitTests/Fixtures/UnitTestFixture.cs | 1+
Msrc/Microsoft.Management.Configuration.UnitTests/Tests/DscModuleV2Tests.cs | 43+++++++++++++++++++++++++++++++++++++++----
4 files changed, 42 insertions(+), 6 deletions(-)

diff --git a/src/Microsoft.Management.Configuration.Processor/Constants/PowerShellConstants.cs b/src/Microsoft.Management.Configuration.Processor/Constants/PowerShellConstants.cs @@ -24,7 +24,7 @@ namespace Microsoft.Management.Configuration.Processor.Constants internal static class Modules { public const string PSDesiredStateConfiguration = "PSDesiredStateConfiguration"; - public const string PSDesiredStateConfigurationMinVersion = "2.0.6"; + public const string PSDesiredStateConfigurationMinVersion = "2.0.7"; public const string PowerShellGet = "PowerShellGet"; public const string PowerShellGetMinVersion = "2.2.5"; public const string PSDesiredStateConfigurationMaxVersion = "2.*"; diff --git a/src/Microsoft.Management.Configuration.Processor/DscModules/DscModuleV2.cs b/src/Microsoft.Management.Configuration.Processor/DscModules/DscModuleV2.cs @@ -21,7 +21,7 @@ namespace Microsoft.Management.Configuration.Processor.DscModule using static Microsoft.Management.Configuration.Processor.Constants.PowerShellConstants; /// <summary> - /// PSDesiredStateConfiguration v2.0.6. + /// PSDesiredStateConfiguration v2. /// </summary> internal class DscModuleV2 : IDscModule { diff --git a/src/Microsoft.Management.Configuration.UnitTests/Fixtures/UnitTestFixture.cs b/src/Microsoft.Management.Configuration.UnitTests/Fixtures/UnitTestFixture.cs @@ -84,6 +84,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Fixtures /// <summary> /// Creates a runspace adding the test module path. /// </summary> + /// <param name="validate">Validate runspace.</param> /// <returns>PowerShellRunspace.</returns> internal IProcessorEnvironment PrepareTestProcessorEnvironment(bool validate = false) { diff --git a/src/Microsoft.Management.Configuration.UnitTests/Tests/DscModuleV2Tests.cs b/src/Microsoft.Management.Configuration.UnitTests/Tests/DscModuleV2Tests.cs @@ -6,6 +6,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests { + using System; using System.IO; using System.Management.Automation; using Microsoft.Management.Configuration.Processor.DscModule; @@ -99,7 +100,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests var dscModule = new DscModuleV2(); - // This doesn't work on 2.0.6 + // This doesn't work on v2 ////var allResources = dscModule.GetDscResourcesInModule( //// testEnvironment.Runspace, //// PowerShellHelpers.CreateModuleSpecification(TestModule.SimpleTestResourceModuleName)); @@ -293,7 +294,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests /// <summary> /// Calls Invoke-DscResource Get. Resource writes error. /// </summary> - [Fact(Skip = "Not supported in PSDesiredStateConfiguration 2.0.6")] + [Fact(Skip = "Not supported in PSDesiredStateConfiguration 2.0.7")] public void InvokeGetResource_ResourceError() { var testEnvironment = this.fixture.PrepareTestProcessorEnvironment(); @@ -384,7 +385,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests /// <summary> /// Calls Invoke-DscResource Test. Resource writes error. /// </summary> - [Fact(Skip = "Not supported in PSDesiredStateConfiguration 2.0.6")] + [Fact(Skip = "Not supported in PSDesiredStateConfiguration 2.0.7")] public void InvokeTestResource_ResourceError() { var testEnvironment = this.fixture.PrepareTestProcessorEnvironment(); @@ -474,7 +475,7 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests /// <summary> /// Calls Invoke-DscResource Set. Resource writes error. /// </summary> - [Fact(Skip = "Not supported in PSDesiredStateConfiguration 2.0.6")] + [Fact(Skip = "Not supported in PSDesiredStateConfiguration 2.0.7")] public void InvokeSetResource_ResourceError() { var testEnvironment = this.fixture.PrepareTestProcessorEnvironment(); @@ -583,5 +584,39 @@ namespace Microsoft.Management.Configuration.UnitTests.Tests Assert.Contains("The property 'Fake' cannot be found on this object.", e.Message); Assert.Equal(ConfigurationUnitResultSource.ConfigurationSet, e.ResultSource); } + + /// <summary> + /// Tests GetDscResourcesInModule with versions. + /// </summary> + [Fact] + public void InvokeSetResource_ModulePathSpaces() + { + // Copy test module to a directory with spaces. + using var tmpDir = new TempDirectory(directoryName: Path.Combine(Guid.NewGuid().ToString(), "Path With Spaces")); + tmpDir.CopyDirectory(this.fixture.TestModulesPath); + var manifestFile = Path.Combine( + tmpDir.FullDirectoryPath, + TestModule.SimpleTestResourceModuleName, + TestModule.SimpleTestResourceManifestFileName); + + var testEnvironment = this.fixture.PrepareTestProcessorEnvironment(); + testEnvironment.CleanupPSModulePath(this.fixture.TestModulesPath); + testEnvironment.AppendPSModulePath(tmpDir.FullDirectoryPath); + + var dscModule = new DscModuleV2(); + + var settings = new ValueSet() + { + { "secretCode", "4815162342" }, + }; + + using PowerShell pwsh = PowerShell.Create(testEnvironment.Runspace); + var testResult = dscModule.InvokeSetResource( + pwsh, + settings, + TestModule.SimpleTestResourceName, + PowerShellHelpers.CreateModuleSpecification( + TestModule.SimpleTestResourceModuleName)); + } } }