Issue
We have a series of .NET Core console apps that are installed in a particular directory:
/users/apps/app1/MyApp1
/users/apps/app2/MyApp2
etc...
The apps run fine. However, we have a problem where the .NET runtime seems to place some files in a ".net" folder in the current user's home directory.
unclejoe@myhost::/home/unclejoe> ls -la
total 40
drwx------. 8 unclejoe mygroup 139 Jan 24 14:42 .
drwxr-xr-x. 90 root root 4096 Jan 21 15:29 ..
-rw-------. 1 unclejoe mygroup 15510 Jan 24 14:42 .bash_history
drwx------. 10 unclejoe mygroup 190 Jan 24 01:42 .net
Within the .net folder, we see a bunch of seemingly temp folders:
[unclejoe@myhost .net]$ ls -la
total 4
drwx------. 10 unclejoe mygroup 190 Jan 24 01:42 .
drwx------. 14 unclejoe mygroup 4096 Jan 23 16:28 ..
drwx------. 4 unclejoe mygroup 46 Jan 24 12:09 MyApp1
drwx------. 5 unclejoe mygroup 66 Jan 24 01:42 MyApp2
Drilling further:
[unclejoe@myhost MyApp1]$ ls -la
total 24
drwx------. 4 unclejoe mygroup 46 Jan 24 12:09 .
drwx------. 10 unclejoe mygroup 190 Jan 24 01:42 ..
drwx------. 2 unclejoe mygroup 8192 Jan 24 01:42 cz1zui3n.uma
drwx------. 2 unclejoe mygroup 8192 Jan 24 12:09 pvwttlkm.z4s
Drilling furthest:
[unclejoe@myhost MyApp1]$ cd cz1zui3n.uma
[unclejoe@myhost cz1zui3n.uma]$ ls -l
total 30808
-rw-r--r--. 1 unclejoe mygroup 330240 Jan 24 01:42 Autofac.dll
-rw-r--r--. 1 unclejoe mygroup 16384 Jan 24 01:42 Autofac.Extensions.DependencyInjection.dll
-rw-r--r--. 1 unclejoe mygroup 143609 Jan 24 01:42 MyApp1.deps.json
-rw-r--r--. 1 unclejoe mygroup 10752 Jan 24 01:42 MyApp1.dll
-rw-r--r--. 1 unclejoe mygroup 149 Jan 24 01:42 MyApp1.runtimeconfig.json
-rw-r--r--. 1 unclejoe mygroup 27136 Jan 24 01:42 Common.dll
The problem is we don't expect these artifacts (dlls/app binaries) to be pushed here as its eating up a lot of space over time, especially when these strange temp directories get created (and never cleaned up on its own). We do not specify any environment variable in our .NET code to point to this home location.
Question:
- Do you know what's causing these directories and files to get created? It appears to get created when the app runs after some period of time.
- Any areas that we should be checking to identify root cause?
Thanks!
Solution
Are the apps published as Single File Applications? If so, the documentation have some pointers.
Looking at the fact that it's extracting 3rd-party libraries, I'm guessing this may be relevant:
Previously in .NET Core 3.0, when a user runs your single-file app, .NET Core host first extracts all files to a directory before running the application. .NET 5 improves this experience by directly running the code without the need to extract the files from the app.
And this explains the location:
If extraction is used the files are extracted to disk before the app starts:
- If environment variable DOTNET_BUNDLE_EXTRACT_BASE_DIR is set to a path, the files will be extracted to a directory under that path.
- Otherwise if running on Linux or MacOS, the files will be extracted to a directory under $HOME/.net.
- If running on Windows, the files will be extracted to a directory under %TEMP%/.net.
Answered By - NPras Answer Checked By - Senaida (WPSolving Volunteer)