The process cannot access the file 'folder name' when trying to install/update via full installer
luislhg opened this issue · 3 comments
Hello, I'm having a issue where the full installer is saying "The process cannot access the file" and I end up with a blank folder and I lose my old installation and the new one.
Log
The log contains the installation of version 8.0.1 which worked, and then the "attempt" to install 8.0.2 with the exceptions.
Squirrel-bug-censored.log
Repro steps
- Install 8.0.1 via Full Installer
- Open 8.0.1 software
- The software will try to download 8.0.2 Full Installer and run it (
Process.Start("MyInstaller.8.0.2.exe")
) - Exception/invalid install as reported above
Note¹: I'm not using the SDK to detect/update. My user has 8.0.1 installed and the software just downloads and runs the latest full installer (8.0.2 in this case).
Note²: It used to work fine with .NET 4.8 and original Squirrel.
Note³: In step 3, I already tried to run a .bat file and close the software. The bat waits for 5 seconds and then runs the installer, there was no process in use when the 8.0.2 installer opened, it still failed with the same exception/error.
Not sure why/how but the only situation where it works is if
- 8.0.1 is opened and running but does not download/install 8.0.1
- User manually downloads and runs 8.0.2 installer
- 8.0.2 installer shut down the running app (forced, as the software did not log it was closing) and 8.0.2 is correctly installed.
This is unexpected though. If my software is properly closed and not running, why would a new version full installer fail to install?
Could you provide a code snippet of your .bat file? I want to better understand what you're doing
Hello, sure.
This is my bat file
@echo off timeout /t 5 start "" "C:\Users\Admin\AppData\Local\Temp\MyInstaller.exe"
I also did check that my softwares process no longer existed after 1-2sec.
Funny enough, if I (user) manually opens the new installer, even if with the software opened, everything works as expected.
Found the issue, it's how Process.Start / ProcessStartInfo is implemented differently in .NET 6.
In .NET 6 I now need to set the WorkingDirectory, otherwise it locks itself to the parent process folder by default.
e.g.: WorkingDirectory = System.IO.Path.GetDirectoryName(processPath)
I'm closing the issue as this is not related to Squirrel.