I am trying to run a simple program on CentOS.
The program:
using System;
namespace helloworld
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
returnHello();
}
static string returnHello()
{
return "hwdy ha";
}
}
}
My publish settings are:
- Configuration: Release|Any CPU
- Target framework: netcoreapp2.1
- Deployment mode: self contained
- target runtime: linux-x64
- target location: bin\Release\netcoreapp2.1\publish\
In a terminal I run
dotnet publish --self-contained -r linux-x64 -c release
Then take the folder \publish and copy it over to my CentOS machine.
using file helloworld, I see the file details:
ELF 64-bit LSB executable, x86-64,version 1(SYSV), dynamically linked (uses shared libs), for GNU/linux.2.6.32, BuildID[sha1]=0x22d087f79061d441f9f6d007bf336f380c1214db, stripped
using uname -r:
3.2.0-3-amd64
In CentOS, I go into the publish folder and run: bash helloworld. In response, I get
helloworld: cannot execute binary file
.
I am not sure what I am missing here, to me it seems the file is targeting the right OS but I cannot execute the file in CentOS. Any help is appreciated. Thanks
cat /etc/*-release. - omajid