-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Publishing a solution with 6.0 exe and 3.1 classlib to the same target path produces a corrupted output #25226
Comments
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. |
The only mentions of that exact error I could find were in dotnet/format#1306 (which has no solution) and dotnet/efcore#27660 where the fix is to add |
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov Issue DetailsDescriptionI created a .NET 6.0 C# project that referenced a .NET Core 3.1 project, published it as a self-contained application and tried to run it on a Linux server, but it threw the FileLoadException below. It turns out it's not even necessary to reference the .NET 3.1 project - it's enough for it to be included in the solution. Reproduction StepsExtract repro.zip and in the repro directory (where repro.sln is) run:
(I originally ran it on a remote server, but the problem still reproduces on the same machine where .NET SDK is installed.) Expected behaviorThe application runs and prints "It ran! (DATE/TIME)" Actual behavior
Regression?Don't know. Known WorkaroundsIt works when not building a self-contained application (but of course then the runtime has to be installed on the target server). ConfigurationHappens on Ubuntu 18.04.6 and Linux Mint 20 (based on Ubuntu 20.04), both x64. $ dotnet --info Runtime Environment: Host (useful for support): .NET SDKs installed: .NET runtimes installed: Other information
|
I tried on Windows - unfortunately it works just fine for me. Couple of questions about your repro:
|
Do you know how I can do that? |
I would expect it to get printed out - is that not the case? The text in your original issue - is that the entire output of the app? If so, you may also want to try runtime tracing: https://docs.microsoft.com/en-us/dotnet/core/dependency-loading/collect-details One other thing I noticed - you added a framework reference to ASP.NET. A better way to do that is to use: <Project Sdk="Microsoft.NET.Sdk.Web"> I don't think it should break the app this way, but give it a try. |
Correct. I called the folder "referenced" because in my real solution the .NET 6 project referenced the .NET 3.1 project, but then I found that I can repro the problem just by having the .NET 3.1 project in the solution, without a reference.
I can see
By itself that works fine:
... but if I add that .NET 3.1 project to the same solution, with the solution file in the consoleproj directory (as per the original repro) I can repro the bug:
So yes, the error in the original issue is the entire output! I tried COREHOST_TRACE per your link ( The repro with a console project instead of an ASP.NET one: |
I tried again on Linux (WSL) and still works for me. |
Sure, here you go: http://files.loop54.com/Files/Evgeny/consoleproj-pub-linux.zip (can't upload that here, probably too big) |
There's something really weird going on. The files are a combination of .NBT 6 (the app, native bits of the runtime like libcoreclr.so), .NET Core 3.1 (most of the System.* assemblies) and .NET Framework 4.* (some of the System.* assemblies, for example System.Runtime.dll). It seems that running In short if the two projects are published in the wrong order (the console app first, then the 3.1 reference) it will produce basically garbage in the output folder. If you run |
@loop-evgeny I moved the issue to the sdk repo (since this is a build-time problem) and updated the title to better match what's going on. As a workaround - run publish on a project directly, not on the solution (or directory in this case), that should make it work. |
Description
I created a .NET 6.0 C# project that referenced a .NET Core 3.1 project, published it as a self-contained application and tried to run it on a Linux server, but it threw the FileLoadException below. It turns out it's not even necessary to reference the .NET 3.1 project - it's enough for it to be included in the solution.
Reproduction Steps
Extract repro.zip and in the repro directory (where repro.sln is) run:
(I originally ran it on a remote server, but the problem still reproduces on the same machine where .NET SDK is installed.)
Expected behavior
The application runs and prints "It ran! (DATE/TIME)"
Actual behavior
Regression?
Don't know.
Known Workarounds
It works when not building a self-contained application (but of course then the runtime has to be installed on the target server).
Configuration
Happens on Ubuntu 18.04.6 and Linux Mint 20 (based on Ubuntu 20.04), both x64.
$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.202
Commit: f8a5561
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/6.0.202/
Host (useful for support):
Version: 6.0.4
Commit: be98e88c76
.NET SDKs installed:
6.0.202 [/usr/share/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Other information
dotnet publish
appears to change which runtime DLLs are included depending on whether the .NET Core 3.1 project is referenced or not, so I'm guessing that the 3.1 version of System.Runtime.dll is getting mixed in somehow. Oddly, this only seems to happen when the .NET Core 3.1 project is outside the solution directory (as it is in the attached repro).The text was updated successfully, but these errors were encountered: