asheroto / winget-install

Install winget tool using PowerShell! Prerequisites automatically installed. Works on Windows 10/11 and Server 2019/2022.
https://bit.ly/winget-install
GNU General Public License v3.0
272 stars 33 forks source link

added support for Windows Server 2019 #43

Closed MatthiasGuelck closed 4 months ago

MatthiasGuelck commented 4 months ago

The changes have been tested with Windows Server 2019, but should also work with Windows Server 2016.

asheroto commented 4 months ago

I haven't forgotten about this, just been busy. Will look at it soon.

asheroto commented 4 months ago

This looks like a great idea. Does not appear to work on Server 2016.

image

Server 2019 looks good at first, but winget doesn't actually work.

image

MatthiasGuelck commented 4 months ago

The result of Windows Server 2016 (Unspecific Error) is not very helpful. Maybe I can find another PC with Windows Server 2016 to test it myself.

During my test on a Windows Server 2019, everything ran smoothly. Can you repeat the call to winget from a CMD?

asheroto commented 4 months ago

You can use Hyper-V and install the Server 2016 ISO even the trial one to test. If I get a chance tomorrow I'll try to grab better output of the error.

MatthiasGuelck commented 4 months ago

Good suggestion. But the problem with 2019 is very unusual. winget seems to run. What happens with "winget upgrade --all"?

MatthiasGuelck commented 4 months ago

I followed your suggestion and installed Windows Server 2019 in a Hyper-V VM. I was able to confirm the problem immediately. To solve the problem for Windows Server 2019, I also installed Visual C++ Redistributable. Now it works fine on Windows Server 2019. I will test Windows Server 2016 accordingly.

MatthiasGuelck commented 4 months ago

On Windows Server 2016:

Add-AppxPackage ".\Microsoft.UI.Xaml.2.8.6\tools\AppX\x64\Release\Microsoft.UI.Xaml.2.8.appx"

Error Message:

Add-AppxPackage : Deployment failed with HRESULT: 0x80073CFD, A Prerequisite for an install could not be satisfied.
Deployment Add operation with target volume C: on Package Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe from:  (Microsoft.UI.Xaml.2.8.appx)  failed with error 0x80073CFD. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment
issues.
NOTE: For additional information, look for [ActivityId] d33c393a-acfc-0003-a24f-3cd3fcacda01 in the Event Log or use the command line Get-AppxLog -ActivityID d33c393a-acfc-0003-a24f-3cd3fcacda01
At line:1 char:1
+ Add-AppxPackage "$WinGetFolderPath\Microsoft.UI.Xaml.2.8.6\tools\AppX ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (C:\Users\Matthi...I.Xaml.2.8.appx:String) [Add-AppxPackage], Exception
    + FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand

And

Get-AppxLog -ActivityID d33c393a-acfc-0000-1a54-3cd3fcacda01

Response:

Time                      ID           Message
----                      --           -------
5/23/2024 1:38:53 PM      301          The calling process is powershell.exe
5/23/2024 1:38:53 PM      603          Started deployment Add operation on a package with main parameter: Microsoft.UI.Xaml.2.8.appx and Options: 0. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.
5/23/2024 1:38:53 PM      157          The app package signature was validated for core content of the app package published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US. Payload won't be validated until the files are read.
5/23/2024 1:38:53 PM      170          The streaming reader was created successfully for app package Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe.
5/23/2024 1:38:53 PM      10002        Creating Resiliency File C:\ProgramData\Microsoft\Windows\AppRepository\2a04af84-58a7-43ca-b7cb-11be4e54c7b0_S-1-5-21-121213482-1509137522-1280790252-1000_2.rslc for Add Operation on Package
                                       Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe.
5/23/2024 1:38:53 PM      607          Deployment Add operation on package Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe has been de-queued and is running for user WIN-BUBQM437E9Q\Matthias.
5/23/2024 1:38:53 PM      613          Adding uri to the list of Uris: file:///C:/Users/Matthias/Downloads/WinGet/Microsoft.UI.Xaml.2.8.6/tools/AppX/x64/Release/Microsoft.UI.Xaml.2.8.appx.
5/23/2024 1:38:53 PM      605          The last successful state reached was BundleProcessed. Failure occurred before reaching the next state Indexed. hr: 0x80073CFD
5/23/2024 1:38:53 PM      401          Deployment Add operation with target volume C: on Package Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe from:  (Microsoft.UI.Xaml.2.8.appx)  failed with error 0x80073CFD. See http://go.microsoft.com/fwlink/?LinkId=235160
                                       for help diagnosing app deployment issues.
5/23/2024 1:38:53 PM      404          AppX Deployment operation failed for package Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe with error 0x80073CFD. The specific error text for this failure is: Deployment Add operation with target volume C: on Package
                                       Microsoft.UI.Xaml.2.8_8.2310.30001.0_x64__8wekyb3d8bbwe from:  (Microsoft.UI.Xaml.2.8.appx)  failed with error 0x80073CFD. See http://go.microsoft.com/fwlink/?LinkId=235160 for help diagnosing app deployment issues.

Don't know how to fix this.

MatthiasGuelck commented 4 months ago

Further investigation: Error "failed with error 0x80073CFD" indicates that the Windows version is too old. Therefore, I have changed the script so that at least Windows Server 2019 is required.

asheroto commented 4 months ago

I think you can use the appropriate aka.ms link from here: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170#latest-microsoft-visual-c-redistributable-version

The $arch var should help you decide which one using an if statement: https://github.com/asheroto/winget-install/blob/835ff7b1e1c32f7056c0bc5039e1067876960ed5/winget-install.ps1#L678-L679

MatthiasGuelck commented 4 months ago

I have taken your suggestions into account and tested the script successfully with the following systems after the latest changes: Windows 10 LTSC (1809) Windows Server 2019 Windows Server 2022

asheroto commented 4 months ago

Sorry for the delay, I was out of town.

On Server 2019, winget still shows as an unrecognized command until you restart the computer. I will add in some help text to account for that.

Thanks for your work on this!

asheroto commented 4 months ago

@MatthiasGuelck I've made some adjustments to the script that improve upon your additions. Pushing out version 4.1.0 now. I also gave you credit in the README.

Thanks again!

MatthiasGuelck commented 4 months ago

On Server 2019, winget still shows as an unrecognized command until you restart the computer. I will add in some help text to account for that.

@asheroto I can't confirm that at all. I have now carried out the installation with my fork on several PCs with Server 2019 and winget was available immediately after running the script on all attempts. This applies both to a fresh installation as Hyper-V and to PCs that have been in operation for some time. Then I tested it again on a fresh Hyper-V installation with your latest script. No reboot was necessary: image

I also don't see why there should be a problem that is solved by a reboot. The whole mess that is necessary with Server 2019 is only due to the fact that the "App Execution Aliases" are not created correctly in Server 2019. They do appear here... image

... but not here: image

Unfortunately, I don't know how to repair the faulty "App Execution Alias". Therefore, the access rights for the path to winget must be adjusted and the path must be added. Both must take effect immediately without a reboot.

asheroto commented 4 months ago

Agreed, upon retesting I no longer have that issue. Works right away.

No matter, I didn't end up adding in any extra instructions anyway. 😊

Thanks for your help!

MatthiasGuelck commented 4 months ago

Some final comments:

asheroto commented 4 months ago
  • Server 2019 should be added to your "About"

Adjusted!

  • the section in the script titled "Visual C++ Redistributable (Server 2019 only)" includes not only VCRedist, but also the customization of access rights and paths.

I added some improvements to the comments.

  • in all other sections the Write-Debug outputs end with "nn", but not in this section - intentional?

Nice catch. This is intentional in some parts of the script but not here. It just kind of depends on what's going on in the script. I re-ran it with and without the Debug param to check where its needed and adjusted accordingly.


Any other feedback before I publish a release? Also added Test-VCRedistInstalled courtesy of #44.

https://github.com/asheroto/winget-install/blob/master/winget-install.ps1

MatthiasGuelck commented 4 months ago

No further comments from my side. I've seen #44, but doesn't that also apply to VCLibs and UI.Xaml? There is also no check before download and installation whether they are already available.

asheroto commented 4 months ago

True, I suppose I should check those too. Visual C++ is more commonly installed but either way won't hurt to check before installing the others.

asheroto commented 4 months ago

Since VCLibs and UI.Xaml are part of the Add-AppxProvisionedPackage command, I think I might just leave it in there to avoid any unnecessary complication.

In testing with Windows Sandbox, I removed VCLibs as it was already installed, but then the installation failed when installing winget. So.... I guess it just really wants the dependency when installing.