microsoft / winget-create

The Windows Package Manager Manifest Creator command-line tool (aka wingetcreate)
MIT License
491 stars 84 forks source link

Cannot download duplicate installer file in interactive mode update (v1.2.5.0) #344

Closed C8H17OH closed 1 year ago

C8H17OH commented 1 year ago

Brief description of your issue

Cannot download duplicate installer file in interactive mode update (v1.2.5.0)

Steps to reproduce

In interactive mode update (wingetcreate update -i), provide the same URL for installers of different architectures.

Expected behavior

Correctly download the file again and generate the manifest in final.

Actual behavior

WingetCreate v1.2.5.0 will throw System.IO.IOException as below:

Failed to download installer.
System.IO.IOException: The process cannot access the file 'C:\Users\****\AppData\Local\Temp\wingetcreate\PowerShell-7.3.2-win.msixbundle' because it is being used by another process.
   at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
   at Microsoft.WingetCreateCore.PackageParser.DownloadFileAsync(String url, Nullable`1 maxDownloadSize)
   at Microsoft.WingetCreateCLI.Commands.BaseCommand.DownloadPackageFile(String installerUrl)
   at Microsoft.WingetCreateCLI.Commands.UpdateCommand.UpdateSingleInstallerInteractively(Installer installer)
   at Microsoft.WingetCreateCLI.Commands.UpdateCommand.UpdateInstallersInteractively(List`1 existingInstallers)
   at Microsoft.WingetCreateCLI.Commands.UpdateCommand.UpdateManifestsInteractively(Manifests manifests)
   at Microsoft.WingetCreateCLI.Commands.UpdateCommand.ExecuteManifestUpdate(List`1 latestManifestContent, CommandExecutedEvent commandEvent)
   at Microsoft.WingetCreateCLI.Commands.UpdateCommand.Execute()
   at Microsoft.WingetCreateCLI.Program.Main(String[] args)

Seems after downloading the previous installer, the process still locks the file just downloaded. This happens on v1.2.5.0, but I haven't seen it in previous versions.

By the way, I never know how to not use interactive mode if multiple architectures share the same installer. It always alerts "The number of new installer packages must match the number of existing installer packages," even if I provide duplicate URLs after -u.

Environment

PS> winget --info
Windows Package Manager v1.4.10173
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.22621.1105
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.19.10173.0
BrandonWanHuanSheng commented 1 year ago

It also happen to me also.

mdanish-kh commented 1 year ago

@C8H17OH @BrandonWanHuanSheng, Is this still occurring in 1.2.6.0? Could you kindly provide an example of a package that you are experiencing this issue with?

By the way, I never know how to not use interactive mode if multiple architectures share the same installer. It always alerts "The number of new installer packages must match the number of existing installer packages," even if I provide duplicate URLs after -u.

You can use the architecture override syntax described in the docs

e.g., wingetcreate update <PackageId> --version <PackageVersion> --urls "<InstallerUrl>|x86", "<InstallerUrl>|x64"...

If the InstallerUrl is same for different scopes, you can append |user , |machine as well

BrandonWanHuanSheng commented 1 year ago

Not sure. I need to confirm afterward.

BrandonWanHuanSheng commented 1 year ago

@C8H17OH @BrandonWanHuanSheng, Is this still occurring in 1.2.6.0? Could you kindly provide an example of a package that you are experiencing this issue with?

By the way, I never know how to not use interactive mode if multiple architectures share the same installer. It always alerts "The number of new installer packages must match the number of existing installer packages," even if I provide duplicate URLs after -u.

You can use the architecture override syntax described in the docs

e.g., wingetcreate update <PackageId> --version <PackageVersion> --urls "<InstallerUrl>|x86", "<InstallerUrl>|x64"...

If the InstallerUrl is same for different scopes, you can append |user , |machine as well

It does not occur on v 1.2.6.0 The issue was gone.

mdanish-kh commented 1 year ago

Ok, so I could reproduce the issue in 1.2.6.0 with a couple of packages

Steps to reproduce

  1. Ensure that developer mode is turned off. (Note: It's strange that sometimes the issue can be reproduced in developer mode, while other times it cannot. This information is provided for reference, but may or may not be directly related to the issue.)
  2. Use interactive update command for Microsoft.WindowsTerminal. This package uses same InstallerUrl for all architectures.
    wingetcreate update Microsoft.WindowsTerminal -i
  3. Use the same/older InstallerUrl as dummy to simulate an upgrade scenario: i.e., (https://github.com/microsoft/terminal/releases/download/v1.16.10261.0/Microsoft.WindowsTerminal_Win10_1.16.10261.0_8wekyb3d8bbwe.msixbundle)

This also occurs with updating Microsoft.WingetCreate, Microsoft.PowerShell in interactive mode (so maybe it's an msixbundle only thing?) I couldn't reproduce with other packages that use the same Url for different architectures i.e., LutzRoeder.Netron, Microsoft.PerfView

BrandonWanHuanSheng commented 1 year ago

I think most likely is msixbundle.