dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.71k stars 1.07k forks source link

dotnet 5 single file extracts files into a temporary folder #16763

Open uffebjorklund opened 3 years ago

uffebjorklund commented 3 years ago

Description

On windows we distribute our application as a single file executable. We have been doing this since dotnet core 3.1 and we had a lot of issues when doing this since the file actually was extracted to a temp folder which caused all kinds of trouble.

In dotnet core 5 the documentation says

Bundling all application-dependent files into a single binary provides an application developer with the attractive option to deploy and distribute the application as a single file. This deployment model has been available since .NET Core 3.0 and has been enhanced in .NET 5.0. Previously in .NET Core 3.0, when a user runs your single-file app, .NET Core host first extracts all files to a temporary directory before running the application. .NET 5.0 improves this experience by directly running the code without the need to extract the files from the app.

This is not true... I am running our application on a win2019 server (clean install), and when I run the application I get temporary folder under C:\Windows\Temp\.net\<MyApplication>\<random-folder-name>.

This is actually even worse than the behavior in 3.1 since we in 3.1 could use DOTNET_BUNDLE_EXTRACT_BASE_DIR to target a custom dir. In dotnet 5 using DOTNET_BUNDLE_EXTRACT_BASE_DIR will use another folder but always add an extra folder with a custom name (in my latest test dvay3ibe.r5m ).

Publish

This is how our application is published

dotnet publish ../src/WindowsService/ -c release -r win-x64 /p:PublishSingleFile=true -o ./

dotnet --info

.NET SDK (reflecting any global.json):
 Version:   5.0.102
 Commit:    71365b4d42

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.10
 OS Platform: Linux
 RID:         ubuntu.20.10-x64
 Base Path:   /usr/share/dotnet/sdk/5.0.102/

Host (useful for support):
  Version: 5.0.2
  Commit:  cb5f173b96

.NET SDKs installed:
  3.1.404 [/usr/share/dotnet/sdk]
  5.0.101 [/usr/share/dotnet/sdk]
  5.0.102 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.10 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download
dotnet-issue-labeler[bot] commented 3 years ago

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.