Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Produce Single File: app crashing #103552

Closed
davidbuchweitz opened this issue Jun 17, 2024 · 6 comments
Closed

Produce Single File: app crashing #103552

davidbuchweitz opened this issue Jun 17, 2024 · 6 comments

Comments

@davidbuchweitz
Copy link

I have a Blazor Server app that runs on kestrel in a Windows service.

Initially everything works perfectly but then after some time I start getting exceptions about certain .NET framework files not being able to load and the app crashes (Blazor red error bar in browser).

I see that by default when using the "Produce Single File" option when publishing, the files are extracted to c:\Windows\Temp\.net\<hash>.

I was under the impression the Temp folder was only cleaned on Windows startup but the internets says files in Temp can be removed in many different cases, such as using Disk Cleanup, running certain updates, on a timer when disk space is low etc.

Either which way, this seems like a terrible oversight for the Temp dir to be used as the extraction point by default.

I've since learned you can set the env var DOTNET_BUNDLE_EXTRACT_BASE_DIR but this is not practical as it would affect all apps published this way. Setting it for this file alone is also not an option as it would require a script to set the env var first.

As a workaround I'm setting HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Wamp.NET\Environment to DOTNET_BUNDLE_EXTRACT_BASE_DIR=C:\Wamp.NET\.wdn\tmp but this is messy.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jun 17, 2024
Copy link
Contributor

Tagging subscribers to this area: @agocke, @vitek-karas, @VSadov
See info in area-owners.md if you want to be subscribed.

@agocke
Copy link
Member

agocke commented Jun 17, 2024

This TEMP behavior is unfortunate, but by-design. However, the default configuration of .NET single-file is to not extract any files to disk. Have you considered turning off bundling?

@davidbuchweitz
Copy link
Author

I haven't changed any defaults - where does this get set? It would be amazing if it could run from memory.

@agocke
Copy link
Member

agocke commented Jun 28, 2024

It should simply be default in .NET 6+. The only bundling done is manual, e.g. by setting IncludeNativeLibrariesForSelfExtract. See https://learn.microsoft.com/en-us/dotnet/core/deploying/single-file/overview?tabs=cli#native-libraries for that setting.

@davidbuchweitz
Copy link
Author

Thanks Andy, but this takes the benefits away from a single file deployment where the app and framework are bundled together in a single file. Made deployment and updates really simple. Back to the drawing board...

@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jun 29, 2024
@agocke
Copy link
Member

agocke commented Jun 29, 2024

Sorry, I don't understand. The whole framework is linked into that exe -- the only native assets that will appear outside the bundle are things outside the core framework. Do you have native assets aside from the ones in the core framework? Or are you using a UI framework that includes native assets?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

2 participants