microsoft / winget-create

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

"System.IO.IOException: The process cannot access the file because it is being used by another process" when manifest has a more than one installer with the same name #333

Closed mivsvit closed 11 months ago

mivsvit commented 1 year ago

Brief description of your issue

When updating the manifest for Mozilla.Thunderbird with wingetcreate update Mozilla.Thunderbird -v 102.6.0 --interactive get the error System.IO.IOException: The process cannot access the file 'C:\Users\UserName\AppData\Local\Temp\wingetcreate\Thunderbird%20Setup%20102.6.0.msi' because it is being used by another process. when updating the 3rd installer.

This appears to be because the 3rd installer in the manifest shares the same filename Thunderbird%20Setup%20102.6.0.msi as the first and wingetcreate is trying to write both files to the same location on disk. The installers are for different locales and are retrieved from different URLs (and have different SHA256 checksums).:

1 of 6 installers:
InstallerLocale: en-US
Architecture: x64
InstallerType: msi
InstallerUrl: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win64/en-US/Thunderbird%20Setup%20102.6.0.msi

3 of 6 installers:
InstallerLocale: en-GB
Architecture: x64
InstallerType: msi
InstallerUrl: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win64/en-GB/Thunderbird%20Setup%20102.6.0.msi

Steps to reproduce

wingetcreate update Mozilla.Thunderbird -v 102.6.0  --interactive

Updating 1 of 6 installers:
InstallerLocale: en-US
Architecture: x64
InstallerType: msi
InstallerUrl: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.5.1/win64/en-US/Thunderbird%20Setup%20102.5.1.msi
InstallerSha256: 53FD96D80CEA31D0F971CD1B2F77C4D6DE2B23793A1BE42763A7D5D61451FC34
ProductCode: '{18D4D2F4-B394-48A2-8886-9C68180CEAD5}'

 What is the new installer url?: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win64/en-US/Thunderbird%20Setup%20102.6.0.msi
 Downloading and parsing: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win64/en-US/Thunderbird%20Setup%20102.6.0.msi...
Installer updated successfully!
Press any key to continue...

Updating 2 of 6 installers:
InstallerLocale: en-US
Architecture: x86
InstallerType: exe
InstallerUrl: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.5.1/win32/en-US/Thunderbird%20Setup%20102.5.1.exe
InstallerSha256: A99DE4AFA3EE30B8E3B2DFBA6E645741895C7B1A12ADC575F28741BB90F3826B
ProductCode: '{18D4D2F4-B394-48A2-8886-9C68180CEAD5}'

 What is the new installer url?: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win32/en-US/Thunderbird%20Setup%20102.6.0.exe
  Downloading and parsing:  https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win32/en-US/Thunderbird%20Setup%20102.6.0.exe
  Installer updated successfully!
Press any key to continue...

 Updating 3 of 6 installers:
InstallerLocale: en-GB
Architecture: x64
InstallerType: msi
InstallerUrl: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.5.1/win64/en-GB/Thunderbird%20Setup%20102.5.1.msi
InstallerSha256: CF415B7775580FDA0F7842844048269621ED68FC800BF84D7F378D1A47E6E8E6
ProductCode: '{18D4D2F4-B394-48A2-8886-9C68180CEAD5}'

 What is the new installer url?: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win64/en-GB/Thunderbird%20Setup%20102.6.0.msi
 Downloading and parsing: https://download-installer.cdn.mozilla.net/pub/thunderbird/releases/102.6.0/win64/en-GB/Thunderbird%20Setup%20102.6.0.msi...
Failed to download installer.
System.IO.IOException: The process cannot access the file 'C:\Users\UserName\AppData\Local\Temp\wingetcreate\Thunderbird%20Setup%20102.6.0.msi' because it is being used by another process.
   at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
   at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   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)

Expected behavior

Expect wingetcreate to accept and then download each new URL successfully and validate the new manifest despite there being more than one installer with the same name.

Actual behavior

Get the error System.IO.IOException: The process cannot access the file 'C:\Users\UserName\AppData\Local\Temp\wingetcreate\Thunderbird%20Setup%20102.6.0.msi and wingetcreate quits when the new URL is submitted for the third installer.

Environment

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

Windows: Windows.Desktop v10.0.22000.1335
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.18.2691.0

Logs: %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\DiagOutputDir

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