microsoft / microsoft/winget-cli
FileContentDsc fails in winget configure
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
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 the FileContentDsc module published by DSC Community.
The KeyValuePairFile resource does not work correctly through winget 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
- Create the following file, replacing
<username>with your username, or choose another writable path:
# save as filecontentdsc.yaml
properties:
configurationVersion: '0.2.0'
resources:
- directives:
allowPrerelease: true
resource: FileContentDsc/KeyValuePairFile
settings:
Ensure: Present
Name: foo
Path: "C:\\Users\\<username>\\test.conf"
Text: bar
- Create the file "C:\Users\<username>\test.conf" with the content:
foo=baz
winget configure .\filecontentdsc.yaml --verbose-logs --accept-configuration-agreements
Expected behavior
I would expect the file to be updated to read:
foo=bar
Actual behavior
The configure command errors out with:
PS C:\Users\egerlach\src\dsc-test> winget configure .\filecontentdsc.yaml --verbose-logs --accept-configuration-agreements
Apply :: KeyValuePairFile
C:\Users\egerlach\test.conf: Set foo to bar
Module: FileContentDsc by DSC Community [Local]
https://github.com/dsccommunity/FileContentDsc
DSC resources for for manipulating the content of text files.
Settings:
Path: C:\Users\egerlach\test.conf
Ensure: Present
Name: foo
Text: bar
You are responsible for understanding the configuration settings you are choosing to execute. Microsoft is not responsible for the configuration file you have authored or imported. This configuration may change settings in Windows, install software, change software settings (including security settings), and accept user agreements to third-party packages and services on your behalf. By running this configuration file, you acknowledge that you understand and agree to these resources and settings. Any applications installed are licensed to you by their owners. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages or services.
Apply :: KeyValuePairFile
The configuration unit failed while attempting to test the current system state.
Cannot process argument transformation on parameter 'Encoding'. 'byte' is not a supported encoding name. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method. (Parameter 'name')
Cannot index into a null array.
<See the log file for additional details>
Some of the configuration was not applied successfully.
Environment
PS C:\Users\egerlach> winget --info
Windows Package Manager v1.6.2771
Copyright (c) Microsoft Corporation. All rights reserved.
Windows: Windows.Desktop v10.0.22621.2428
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.2771.0
Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User) %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User) %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root C:\Program Files\WinGet\Packages
Portable Package Root (x86) C:\Program Files (x86)\WinGet\Packages
Installer Downloads %USERPROFILE%\Downloads
Links
---------------------------------------------------------------------------
Privacy Statement https://aka.ms/winget-privacy
License Agreement https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale
Admin Setting State
--------------------------------------------------
LocalManifestFiles Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride Disabled
LocalArchiveMalwareScanOverride Disabled
PS C:\Users\egerlach\src\workstation-setup> Get-Module
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Manifest 2.0.0 preview00… FileContentDsc
Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-Item, Clear-It…
Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Ob…
Script 1.4.8.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package,…
Script 2.2.5 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Fin…
Script 2.0.7 PSDesiredStateConfiguration {Configuration, Get-DscResource, Invoke-DscResour…
Script 2.2.6 PSReadLine {Get-PSReadLineKeyHandler, Get-PSReadLineOption, …
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the winget configure .\filecontentdsc.yaml --verbose-logs --accept-configuration-agreements command with the linked gist inputs and full log. Compare the configure execution with direct PowerShell invocation of FileContentDsc/KeyValuePairFile, focusing on the unsupported byte encoding and null-array errors. Done means the configuration updates foo=baz to foo=bar successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- powershell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100