I have a very simple question. When I use donet build on a c# project in ubuntu it outputs a .dll file. I was wondering why or how it does that and why does it not output a .so file ?
Because .NET Core (and .NET as a whole) uses the Portable Executable format even for other platforms, it's still technically a dynamic link library.
The .NET Core run-time loader can read and run it fine.
You can read more here - .NET assembily file format
.NET Core uses it's own file system that has to be ran with a specific command in order to run the application.
(It) relies on the presence of a shared system-wide version of .NET Core on the target system
To run the application you type in
dotnet {FileName}.dll
This will start running the application using the .NET Core framework.
Your app contains only its own code and any third-party dependencies
that are outside of the .NET Core libraries. FDDs contain .dll files
that can be launched by using the dotnet utility from the command
line. For example, dotnet app.dll runs an application named app.
Source: .NET Core Application Deployment
Related
If I create a simple .Net Core 3.1 console app on my Windows machine, should I be able to copy the output folder over to Debian 9 machine and the console program just work?
Because it's not.
./ConsoleApp1.exe - does not work.
Most likely you'll also find a 'ConsoleApp1.dll' file in your output folder, which is your actual application (the .exe is only a wrapper for Windows).
You should be able to run your application on any platform with the .NET Core runtime installed like this:
dotnet ConsoleApp1.dll
I have a c# nuget package that uses some native (c++) code, which supports cross-platform development, meaning that when you call the c# nuget from another project, depending on the OS it will either pull the .so files (linux) or the .dll files (windows).
Now I have a console app to test some code (.net core 3), which also calls indirectly the above mentioned c# nuget. I want to build and run this console app in ubuntu 18.04. Problem is, when I build the console app, I get the .so files as expected, but when I run it, the app looks for the .dll files and complains that they are not there (which they are not, so I get a DLLNotFound Exception). Does anyone know why during build time a console app in linux builds with a "windows behavior" ? I guess it has something to do with the way .NET builds stuff in linux.
P.S. : When I use the aforementioned c# nuget as a microservice in a linux environment, everything works fine.
I am trying to publish my self-contained .NET Core Library for my Electron/Edge Application.
After publishing, my dll is located in the Publish output. However, it is missing all of the .NET Core Runtime files that .NET Core needs to be self-contained.
When publishing the same exact project as a Console App with the OutputType set to "Exe". It works fine, and all .NET Core Runtime files are located in the Publish folder output.
I am unsure as to why I am unable to make a self-contained library, so I can invoke the methods from my electron app via Edge. If someone could enlighten me as to why the .NET Core Runtime dependencies only show up in the publish output if it is a Console App that would be great.
Any information on how I can achieve my goal would also be appreciated.
Thank you.
If you add the --self-contained argument to your publish, it will create the runtime files with your library. This is solved, thank you.
I've created a simple .NET core console app targeting .NET Core Framework 1.1. When I build it, it creates an assembly file named DotNetCoreConsoleApp.dll in the \bin\debug folder. So there is nothing that I can double click and run directly but interestingly when I start debugging the project by pressing F5 then Visual Studio is able to launch a process.
Project configuration of my project is as below:
How windows will be able to launch such an application process without any exe file? I understand that Windows only understands a file as starting point of a process if it contains PE header.
There is no exe file.
From msdn:
"Short answer, there isn’t one. When you compile your .NET Core console application for example, you get a DLL. Then you execute it using the DOTNET command from the .NET Core SDK found here."
From a different answer on stackoverflow (Visual Studio 2017 missing exe file):
You have two options:
If you want an EXE, you need to target the .NET Framework.
If you don't want to change your code, then you need to install .NET Core on the server and run dotnet pathToDll on a command line
https://blogs.msdn.microsoft.com/benjaminperkins/2017/03/07/net-core-application-where-is-my-exe-how-to-publish/
I've created a .NET Core console application. I want to build the app so that I can execute it on Windows or MacOS without dotnet core being installed on the machine. So I need e.g. for windows an exe.
I've read https://learn.microsoft.com/de-de/dotnet/articles/core/tools/dotnet-publish and I know how to compile the application for the different platform(s).
But no executable gets created. What am I missing here and how do I accomplish my goal?
What you need is to create a self-contained application. The link explains how exactly to modify your project.json to do that.
Also note that while a self-contained application does not have a dependency on .Net Core, it may have other dependencies. Specifically on OSX, I believe you will need to install a specific version of openssl from homebrew.