Open egerlach opened 1 year ago
I did a couple of tests based on the error.
I tried to set Encoding: ASCII
even though the Wiki states it's the default since the error was Encoding
. byte
is not a supported encoding name.
If the file doesn't exist, the configuration will succeed and create the file. I think this might be a bug in the DSC Resource.
How did you test with PowerShell directly?
PS C:\Users\egerlach\src\workstation-setup> cat C:\Users\egerlach\test.conf
foo=false
PS C:\Users\egerlach\src\workstation-setup> Invoke-DscResource -Name KeyValuePairFile -Method Set -ModuleName FileContentDsc -Property @{
>> Path = 'c:\Users\egerlach\test.conf'
>> Name = 'foo'
>> Ensure = 'Present'
>> Text = 'bar'
>> }
RebootRequired
--------------
False
PS C:\Users\egerlach\src\workstation-setup> cat C:\Users\egerlach\test.conf
foo=bar
It could absolutely be a bug in the resource. I'll admit I'm a n00b with DSC, though I know my way around PS okay. Based on what I was reading in the error logs it looked like it might be a problem with how this particular resource was invoked rather than with the resource itself. I'm not set up to debug through the winget-cli code into the resource invocation though, so I didn't know how I could proceed further.
Do you see the same thing in terms of calling Invoke DSC Resource failing to modify the key value pairs when the file exists with a different value?
It seems to work when there is no file (it creates one with the right key value pair), and it seems to return $true
when the file has the correct pair. It only fails for me to change the value of the "value" in the pair.
Brief description of your issue
I am experimenting with the new
winget configure
system, and loving it so far. I wanted to start using it to edit some files, and selected theFileContentDsc
module published by DSC Community.The
KeyValuePairFile
resource does not work correctly throughwinget configure
, though it works when invoked in Powershell directly.I debated where to file this issue and eventually decided to at least start here because the resource works correctly when invoked directly from Powershell but fails when invoked from winget.
I've provided input files, command output and logs in a gist.
Steps to reproduce
<username>
with your username, or choose another writable path:winget configure .\filecontentdsc.yaml --verbose-logs --accept-configuration-agreements
Expected behavior
I would expect the file to be updated to read:
Actual behavior
The configure command errors out with:
Full log
Environment