1

I downloaded a C# project from github and compiled it with Visual Studio using the dotnet build command and apparently everything went well. But I can't use it on Centos, not even using Mono . Which command should I use to compile a C# project in VisualStudio for use on Linux? I used dotnet build which generated me a project with .exe file and I tried to run it with Mono and I got this error File does not contain a valid CIL image.

sorry if this is the wrong area to ask

Adrian
  • 23
  • 3

1 Answers1

0

There are different ways to do it and they depend on what you're trying to achieve.

From .NET application publishing overview

Type Command
framework-dependent executable for the current platform. dotnet publish
framework-dependent executable for a specific platform. dotnet publish -r --self-contained false
framework-dependent cross-platform binary. dotnet publish
self-contained executable. dotnet publish -r

From the Examples section:

Publish an app cross-platform framework-dependent. A Linux 64-bit executable is created along with the dll file. This command doesn't work with .NET Core SDK 2.1.

dotnet publish -r linux-x64 --self-contained false

You may be interested in Single-file deployment and executable:

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. Single-file deployment is available for both the framework-dependent deployment model and self-contained applications.

tymtam
  • 31,798
  • 8
  • 86
  • 126