Project executing works on console but not in Rider run configurations
Hey there,
I've tried opting to Rider for .NET Linux development but it keeps hitting me with random problems every time.
I'm trying to run and debug my Console Application, which is referencing two .NET Core libraries, but to no avail. Everything is targeting .NET 5.
I've tried using .NET Project and .NET Executable for the console app (named Squati.ConsoleApp) but both keep throwing random complaints.
For instance:
/usr/share/dotnet/dotnet /.../webapps/squati/server/Squati.ConsoleApp/bin/Debug/net5.0/Squati.ConsoleApp.dll
Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Squati.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Squati.App, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
And sometimes randomly in the build
4>CSC: Error CS0006 : Metadata file '/.../webapps/squati/server/Squati.App/bin/Debug/net5.0/ref/Squati.App.dll' could not be found
Also
/usr/share/dotnet/dotnet /.../webapps/squati/server/Squati.ConsoleApp/bin/Debug/net5.0/Squati.ConsoleApp.dll
Cannot use file stream for [/.../webapps/squati/server/Squati.ConsoleApp/bin/Debug/net5.0/Squati.ConsoleApp.deps.json]: No such file or directory
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/.../webapps/squati/server/Squati.ConsoleApp/bin/Debug/net5.0/'.
Failed to run as a self-contained app.
I've been trying to rebuild and clean build every time I try to run the app and something seems to work sometimes at some point but I just can't figure out what exactly is wrong. The DLLs are outputting fine most of the time to the debug/net5.0 directory - sometimes when I build it just disappears. I tried with and without the Resharper build engine.
What's most absurd is that using the `dotnet run` and `dotnet build` (which is referencing /usr/bin/dotnet) works without any problems.
Please sign in to leave a comment.
Alright so after some digging and some trial and error, I might have found a solution or an approach to these problems.
The first two (DLL / Metadata not found) could be solved by re-organizing / refreshing the build order. This is done by editing the Properties of the .sln, unchecking everything, clicking ok, going back and checking the order of the build, clicking ok; one by one. This would probably change the .sln file.
The third one, regarding ".deps.json not found", could be solved by adding the following to the <PropertyGroup> of the .csproj
Hello, thank you for reporting the issue and sharing the solution that worked for you. The initial issue seems to be related to the wrong build order, not counting build dependencies if they are specified indirectly. It looks like the following known issue: RIDER-43710. So the solution suggested there is to build dependencies so they can be built in parallel or decrease number of processes in Build Parameters to 1. Let me know if you have other questions.