Runtime: .NET Core Single EXE extraction folder logic not documented

Created on 10 Dec 2019  Â·  17Comments  Â·  Source: dotnet/runtime

Issue Title

The extraction logic for .NET core single-exe file doesn't seem to be documented and makes troubleshooting difficult. While I understand the codebase is open source, it is huge and it would be nice to have this documented as I am facing issues where users cannot boot the app due to what appears to be bugs in the single-exe extraction process.

General

I have been troubleshooting issues with a few of the users where my apps will no longer boot after a new version of the application has been extracted and the only solution is to wipe the temp folder where the actual app .dll is stored. Looking at the event logs, when the user clicks on my single-exe, it will extract to a folder in %localappdata%\temp\.net\. It will then call and run that local .net core 'installation' and run the dll located there.

My app updates by downloading a new exe, running it in the background (no ui starts), which extracts. It then reboots to a temporary swap file which moves the new exe (that just exited after extracting itself) back to the original exe's place. This makes it appear like there was a quick swap rather than a long swap (first boot takes like 15s while it extracts. A splash screen would be a nice feature for this long extraction) while it extracts the entire exe into place. I'm not sure if this is appropriate as I do not understand the logic behind the extraction code, it seems generates a random folder but I am not sure if it's actual random.

An example error message my users have seen from event viewer:

Description: A .NET Core application failed.

Application: ME3TweaksModManager.exe
Path: E:\Dokumenty\Mass Effect 3\ME3TweaksModManager\ME3TweaksModManager.exe
Message: The application to execute does not exist: 'C:\Users\piotr\AppData\Local\Temp\.net\ME3TweaksModManager\0x4rkytj.h1w\ME3TweaksModManager.dll'

Event viewer message

This doesn't appear to have to do with my code, rather it has to do with the .net core wrapper for single exe. My exe's are not trimmed (as it breaks the app horrendously and I only save a couple of MB). This only affects a few users.

The last one I helped said that once they put the downloaded file as the same location as the original exe - aka, they had 2 copies at once point, and the 2nd one could not boot - it would work. Which is why I am asking, why is this error occurring? What is determining the foldername in appdata?

area-Host area-Single-File documentation

Most helpful comment

Regarding the failure you see:
I think what happened is that the files within %TEMP%\.net\<appName>\<id>\* were deleted by Windows, but the containing directory itself wasn't deleted yet. So, in this intermediate state, the .net host tries to reuse the extraction, but fails.

We're considering a service fix to re-extract the contents of the bundle on failure within the host.

In the meantime, by setting DOTNET_BUNDLE_EXTRACT_BASE_DIR, you can extract to a non-temporary location where the OS doesn't cleanup the files, thus circumventing the failure.

All 17 comments

@jeffschwMSFT

@swaroop-sridhar

@Mgamerz the extraction logic is documented in the [design-docs] (https://github.com/dotnet/designs/blob/master/accepted/single-file/extract.md#extraction-location).

However, we certainly need documentation on Microsoft Docs site. We don't have documentation on PublishSingleFile (or any core 3.0 SDK options) yet on the official page.

Regarding the failure you see:
I think what happened is that the files within %TEMP%\.net\<appName>\<id>\* were deleted by Windows, but the containing directory itself wasn't deleted yet. So, in this intermediate state, the .net host tries to reuse the extraction, but fails.

We're considering a service fix to re-extract the contents of the bundle on failure within the host.

In the meantime, by setting DOTNET_BUNDLE_EXTRACT_BASE_DIR, you can extract to a non-temporary location where the OS doesn't cleanup the files, thus circumventing the failure.

Hopefully there is a service fix in the near future, as I am starting to notice many of my users are affected by this. I don't run an enterprise grade application, but I do make a lot of releases, so keeping track of all of the version numbers is not super simple (especially since I use an SFX archive to extract the self-extracting exe as it cuts the size almost 75% down - if I am doing single exe that seems like it would be a good feature to have?), and having my end users manually delete the temp folder is not really something I like them doing.

@Mgamerz yes, I expect that this issue will be fixed in the next servicing early next year. In the meantime, probably the better option for users is to set DOTNET_BUNDLE_EXTRACT_BASE_DIR instead of recycling the tmp directory.

The changelog notes for 3.1.1 don't appear to indicate this issue was fixed. Is this the target release for a fix?

@Mgamerz fix for this issue is under development; I expect this issue be fixed in the Feb or March servicing release.

@swaroop-sridhar any update?
Thx you.

I'm also wondering about an update

@nuzolx, @lanndoc Recovering missing extracted-files at startup is released in 3.1.4 SDK.
https://dotnet.microsoft.com/download/dotnet-core/3.1

The above link at https://github.com/dotnet/designs/blob/master/accepted/single-file/extract.md#extraction-location is now dead. I can't find where this path is on Linux anymore (a library I use does not work on .net 5 on linux right now) - where did this get moved to?

So where the docs? This issue still happen.

I can confirm I still have users that have this issue. Its a lot less
common than before, but I still have them wipe out the folder from
temp/.net and it fixes it.

On Mon, Nov 23, 2020, 8:46 AM GFHuang notifications@github.com wrote:

So where the docs? This issue still happen.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/dotnet/runtime/issues/739#issuecomment-732243307, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAU4VFGJ4OEWV7R4IEK7F53SRJ7URANCNFSM4JZES3NA
.

How to extract a file that embedded into single exe at the runtime?

Was this page helpful?
0 / 5 - 0 ratings