microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.62k stars 1.4k forks source link

Failure to install Visual Studio workloads with VSComponents step #3914

Open flowcoder1 opened 7 months ago

flowcoder1 commented 7 months ago

Brief description of your issue

Cannot install Visual Studio 2022 Community workloads using the Microsoft.VisualStudio.DSC/VSComponents resource, either via winget configure or DevHome. Tested on two machines plus Windows Sandbox.

Fails with:

Apply :: VSComponents
  The configuration unit was not in the module as expected.

Tried installing the modules separately with Install-Module -Name Microsoft.VisualStudio.DSC -AllowPrerelease but it didn't help.

Steps to reproduce

Using the following configuration file with winget configure .\configuration.dsc.yaml --verbose-logs :

# yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2
# Reference: https://github.com/microsoft/terminal#prerequisites
properties:
  assertions:
    - resource: Microsoft.Windows.Developer/OsVersion
      directives:
        description: Verify min OS version requirement
        allowPrerelease: true
      settings:
        MinVersion: '10.0.22000'
  resources:
    - resource: Microsoft.Windows.Developer/DeveloperMode
      id: DeveloperMode
      directives:
        description: Enable Developer Mode
        allowPrerelease: true
      settings:
        Ensure: Present
    - resource: Microsoft.WinGet.DSC/WinGetPackage
      id: vsPackage
      directives:
        description: Install Visual Studio 2022 (any edition is OK)
        allowPrerelease: true
      settings:
        id: Microsoft.VisualStudio.2022.Community
        source: winget
    - resource: Microsoft.VisualStudio.DSC/VSComponents
      dependsOn:
        - vsPackage
      directives:
        description: Install required VS workloads
        allowPrerelease: true
      settings:
        productId: Microsoft.VisualStudio.Product.Community
        channelId: VisualStudio.17.Release        
        components:
          - Microsoft.VisualStudio.Workload.ManagedDesktop
          - Microsoft.VisualStudio.Workload.Universal
  configurationVersion: 0.2.0

This results in:

Assert :: OsVersion
  Configuration successfully applied.
Apply :: DeveloperMode [DeveloperMode]
  Configuration successfully applied.
Apply :: WinGetPackage [vsPackage]
  Configuration successfully applied.
Apply :: VSComponents
  The configuration unit was not in the module as expected.
Some of the configuration was not applied successfully.

Expected behavior

Visual Studio to install the required components. It also doesn't work with specifying a .vsconfig file.

Actual behavior

The Visual Studio installer installs, but none of the components install.

Environment

Windows Package Manager v1.6.3133
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.1702
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.21.3133.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
denelon commented 7 months ago

Was the configuration run in user mode or administrator? I believe the resource requires administrator.

flowcoder1 commented 7 months ago

Was the configuration run in user mode or administrator? I believe the resource requires administrator.

I ran it from both an Administrator Powershell and with the run-as-admin option from Dev Home

2023-11-20 11:15:14.092 [CORE] WinGet, version [1.6.3133], activity [{0D27F8C7-3723-4F82-A16F-56940352D403}]
2023-11-20 11:15:14.095 [CORE] OS: Windows.Desktop v10.0.22621.1702
2023-11-20 11:15:14.096 [CORE] Command line Args: "C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps\winget.exe" configure .\configuration.dsc.yaml --verbose-logs
2023-11-20 11:15:14.096 [CORE] Package: Microsoft.DesktopAppInstaller v1.21.3133.0
2023-11-20 11:15:14.096 [CORE] IsCOMCall:0; Caller: winget-cli
2023-11-20 11:15:14.102 [CLI ] WinGet invoked with arguments: 'configure' '.\configuration.dsc.yaml' '--verbose-logs'
2023-11-20 11:15:14.103 [CLI ] Found subcommand: configure
2023-11-20 11:15:14.103 [CLI ] Leaf command to execute: root:configure
2023-11-20 11:15:14.103 [CLI ] Executing command: configure
2023-11-20 11:15:14.131 [CONF] Launching process for configuration processing...
2023-11-20 11:15:14.140 [CONF]   Configuration remote PID is 8400
2023-11-20 11:15:14.339 [CONF] ... configuration processing connection established.
2023-11-20 11:15:14.342 [CONF] Applying built in additional module path: C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.21.3133.0_x64__8wekyb3d8bbwe\ExternalModules
2023-11-20 11:15:14.701 [CONF] [CONF] Parsing configuration set:
2023-11-20 11:15:14.701 [CONF] # yaml-language-server: $schema=https://aka.ms/configuration-dsc-schema/0.2

# Reference: https://github.com/microsoft/terminal#prerequisites

properties:

  assertions:

    - resource: Microsoft.Windows.Developer/OsVersion

      directives:

        description: Verify min OS version requirement

        allowPrerelease: true

      settings:

        MinVersion: '10.0.22000'

  resources:

    - resource: Microsoft.Windows.Developer/DeveloperMode

      id: DeveloperMode

      directives:

        description: Enable Developer Mode

        allowPrerelease: true

      settings:

        Ensure: Present

    - resource: Microsoft.WinGet.DSC/WinGetPackage

      id: vsPackage

      directives:

        description: Install Visual Studio 2022 (any edition is OK)

        allowPrerelease: true

      settings:

        id: Microsoft.VisualStudio.2022.Community

        source: winget

    - resource: Microsoft.VisualStudio.DSC/VSComponents

      dependsOn:

        - vsPackage

      directives:

        description: Install required VS workloads

        allowPrerelease: true

      settings:

        productId: Microsoft.VisualStudio.Product.Community

        channelId: VisualStudio.17.Release        

        components:

          - Microsoft.VisualStudio.Workload.ManagedDesktop

          - Microsoft.VisualStudio.Workload.Universal

  configurationVersion: 0.2.0
2023-11-20 11:15:14.701 [CONF] [YAML] Detected UTF-8
2023-11-20 11:15:14.855 [CONF] Creating set processor for `configuration.dsc.yaml`...
2023-11-20 11:15:16.388 [CONF] Using winget module path
2023-11-20 11:15:16.389 [CONF]   Effective module path:
C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WinGet\Configuration\Modules;C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.21.3133.0_x64__8wekyb3d8bbwe\ExternalModules;C:\Users\WDAGUtilityAccount\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.desktopappinstaller_1.21.3133.0_x64__8wekyb3d8bbwe\configurationremotingserver\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
2023-11-20 11:15:20.000 [CONF] PowerShellCommands: ['Import-Module' Parameters: FullyQualifiedName = '@{ ModuleName = 'PSDesiredStateConfiguration'; ModuleVersion = '2.0.7'; MaximumVersion = '2.999999999' }' ]

2023-11-20 11:15:20.000 [CONF] ... done creating set processor.
2023-11-20 11:15:20.041 [CONF] Getting unit details [ReadOnly] for: OsVersion [Microsoft.Windows.Developer]
2023-11-20 11:15:21.388 [CONF] Getting unit details [ReadOnly] for: DeveloperMode [Microsoft.Windows.Developer]
2023-11-20 11:15:22.266 [CONF] Getting unit details [ReadOnly] for: WinGetPackage [Microsoft.WinGet.DSC]
2023-11-20 11:15:23.145 [CONF] Getting unit details [ReadOnly] for: VSComponents [Microsoft.VisualStudio.DSC]
2023-11-20 11:15:23.634 [CONF] PowerShellCommands: ['Get-DscResource' Parameters: Name = 'VSComponents' Module = 'Microsoft.VisualStudio.DSC' ]

[WriteError] The term 'VSComponents' is not recognized as the name of a Resource.

2023-11-20 11:15:32.019 [CONF] Creating set processor for `configuration.dsc.yaml`...
2023-11-20 11:15:32.228 [CONF] Using winget module path
2023-11-20 11:15:32.228 [CONF]   Effective module path:
C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WinGet\Configuration\Modules;C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.21.3133.0_x64__8wekyb3d8bbwe\ExternalModules;C:\Users\WDAGUtilityAccount\Documents\PowerShell\Modules;C:\Program Files\PowerShell\Modules;c:\program files\windowsapps\microsoft.desktopappinstaller_1.21.3133.0_x64__8wekyb3d8bbwe\configurationremotingserver\Modules;c:\program files\powershell\7\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
2023-11-20 11:15:32.638 [CONF] ... done creating set processor.
2023-11-20 11:15:32.642 [CONF] Creating unit processor for: OsVersion [Microsoft.Windows.Developer]...
2023-11-20 11:15:33.041 [CONF] ... done creating unit processor.
2023-11-20 11:15:33.042 [CONF] Using unit from location: C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WinGet\Configuration\Modules\Microsoft.Windows.Developer\0.1.3\Microsoft.Windows.Developer.psd1
2023-11-20 11:15:33.044 [CONF] Invoking `Test` for resource: OsVersion [Microsoft.Windows.Developer]...
2023-11-20 11:15:36.004 [CONF] ... done invoking `Test`.
2023-11-20 11:15:36.078 [CONF] Creating unit processor for: DeveloperMode [Microsoft.Windows.Developer]...
2023-11-20 11:15:36.490 [CONF] ... done creating unit processor.
2023-11-20 11:15:36.490 [CONF] Using unit from location: C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WinGet\Configuration\Modules\Microsoft.Windows.Developer\0.1.3\Microsoft.Windows.Developer.psd1
2023-11-20 11:15:36.491 [CONF] Invoking `Test` for resource: DeveloperMode [Microsoft.Windows.Developer]...
2023-11-20 11:15:36.954 [CONF] ... done invoking `Test`.
2023-11-20 11:15:37.216 [CONF] Creating unit processor for: WinGetPackage [Microsoft.WinGet.DSC]...
2023-11-20 11:15:38.012 [CONF] ... done creating unit processor.
2023-11-20 11:15:38.012 [CONF] Using unit from location: C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WinGet\Configuration\Modules\Microsoft.WinGet.DSC\0.2.0\Microsoft.WinGet.DSC.psd1
2023-11-20 11:15:38.012 [CONF] Invoking `Test` for resource: WinGetPackage [Microsoft.WinGet.DSC]...
2023-11-20 11:15:41.796 [CONF] ... done invoking `Test`.
2023-11-20 11:15:41.942 [CONF] Creating unit processor for: VSComponents [Microsoft.VisualStudio.DSC]...
2023-11-20 11:15:42.356 [CONF] PowerShellCommands: ['Get-DscResource' Parameters: Name = 'VSComponents' Module = 'Microsoft.VisualStudio.DSC' ]

[WriteError] The term 'VSComponents' is not recognized as the name of a Resource.

2023-11-20 11:15:45.328 [CONF] PowerShellCommands: ['Get-DscResource' Parameters: Name = 'VSComponents' Module = 'Microsoft.VisualStudio.DSC' ]

[WriteError] The term 'VSComponents' is not recognized as the name of a Resource.

2023-11-20 11:15:45.356 [CONF] Microsoft.Management.Configuration.Processor.Exceptions.InstallDscResourceException: Unable to find resource after install: VSComponents [Microsoft.VisualStudio.DSC]

   at Microsoft.Management.Configuration.Processor.Set.ConfigurationSetProcessor.PrepareUnitForProcessing(ConfigurationUnitInternal unitInternal)

   at Microsoft.Management.Configuration.Processor.Set.ConfigurationSetProcessor.CreateUnitProcessor(ConfigurationUnit unit)
2023-11-20 11:15:45.359 [CONF] [FAIL] Microsoft.Management.Configuration.dll!00007FFB3877BF76: LogHr(1) tid(8ac) 8A15C101 
2023-11-20 11:15:45.360 [CONF] [CONF] Unit Processor exception: 8a15c101 [The text associated with this error code could not be found.]
2023-11-20 11:15:45.608 [CONF] Configuration unit VSComponents[] failed with code 0x8a15c101 and error message:
The text associated with this error code could not be found.

2023-11-20 11:15:45.612 [CLI ] Terminating context: 0x8a15c005 at C:\__w\1\s\external\pkg\src\AppInstallerCLICore\Workflows\ConfigurationFlow.cpp:3f1
denelon commented 7 months ago

Does (Get-DscResource VSComponents).Properties respond with the properties in PowerShell 7?

flowcoder1 commented 7 months ago

Does (Get-DscResource VSComponents).Properties respond with the properties in PowerShell 7?

PS C:\Users\WDAGUtilityAccount\Desktop\.configurations> (Get-DscResource VSComponents).Properties
Get-DscResource: The 'Get-DscResource' command was found in the module 'PSDesiredStateConfiguration', but the module could not be loaded. For more information, run 'Import-Module PSDesiredStateConfiguration'.
PS C:\Users\WDAGUtilityAccount\Desktop\.configurations> Import-Module PSDesiredStateConfiguration
Import-Module: Failure from remote command: Import-Module -Name 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psd1': Could not load file or assembly 'file:///C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\Microsoft.Windows.DSC.CoreConfProviders' or one of its dependencies. The system cannot find the file specified.
flowcoder1 commented 7 months ago

I think the latest version published on the Powershell Gallery (https://www.powershellgallery.com/packages/Microsoft.VisualStudio.DSC/1.0.18-beta) may be broken. I just did a Install-Module -Name Microsoft.VisualStudio.DSC -RequiredVersion 1.0.15-beta -AllowPrerelease and then we get:

PS C:\Users\darob> (Get-DscResource VSComponents).Properties

Name                 PropertyType   IsMandatory Values
----                 ------------   ----------- ------
channelId            [string]              True {}
productId            [string]              True {}
components           [string[]]           False {}
DependsOn            [string[]]           False {}
includeOptional      [bool]               False {}
includeRecommended   [bool]               False {}
PsDscRunAsCredential [PSCredential]       False {}
vsConfigFile         [string]             False {}

The VSComponents step now runs with this rollback of the version and I see the workload artifacts being installed.

denelon commented 7 months ago

Did you file a bug for them at VisualStudioDSC

flowcoder1 commented 7 months ago

Yes, just raised at:

https://github.com/microsoft/VisualStudioDSC/issues/17