sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Unable to run .Net Core App on Linux Machine

Open ms0713 opened this issue 8 years ago • 2 comments

Steps to reproduce

My objects are running fine on Windows machine.

I build my project using <PackageReference Include="Microsoft.NETCore.Targets" Version="2.0.0" /> to my.csproj file through Visual Studio 2017.

I have used two following references explicitly:

<PackageReference Include="Syste.Data.SqlClient" Version="4.4.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.0">

My project type is .Net Core console app which references 5 other .NetStandard libraries. My .NET Version is netcoreapp2.0 I m using Visual Studio Professional 2017 version 15.7.5.

I am able to publish the objects successfully. My publish profile is as following: Configuration : Release|x64 Target Framework : netcoreapp2.0 Deployment Mode : Self-contained Target Runtime : linux-x64 or rhel.7-x64

Then I publish and run the objects on Linux machine.

Output : It is returning console back immediately.

I also did publish my code using coomand dotnet publish ABC.dll -r rhel.7-x64. Then I copied complete publish folder on Linux Machine. After running published objects on Linux machine, console returns back without running the application.

I tried sample .Net Core application without any dependecy, it works fine on Linux machine.

I also noticed one thing that while publishing, It puts all the dependent dls and so files in the same folder. When I open deps.json file, it shows paths like

lib/netstandard2.0/Microsoft.EntityFrameworkCore.dll
runtimes/unix/lib/netstandard2.0/Microsoft.Win32.Registry.dll

Is this dependent dlls path needs to be corrected in deps.json file??? My publish folder does not contain any runtimes or lib folder.

Expected behavior

It should run successfully on linux machine.

Actual behavior

It is returning console back immediately after running it through linux machine command prompt.

Environment data

I have updated .NEt Core SDK with version 2.1.0. I am able to run my older objects build with .Net Core SDK version 2.0.0 on Linux Machine successfully.

I have installed Microsoft .Net Core SDK 2.1.302 on Windows machine. On windows machine dotnet --version command returns me 2.0.0

I have installed .Net Core SDK 2.0.3 on Linux Machine. On Linux machine dotnet --version command returns me 2.0.3

Is this version mismatch between OS can be a problem??

ms0713 avatar Sep 20 '18 04:09 ms0713

Could you please share a repro of this issue in a github repo? Or maybe share your csproj? I don't quite follow all your comments about how you modified your csproj.

Also, how are you running dotnet publish on a dll? Did you mean you are running dotnet publish abc.csproj -r rhel.7-x64 instead of dotnet publish abc.dll...?

I believe the json file is correct. The fact that the console app is returning without any errors or exceptions throw might there that the application is actually running but something in your code is causing it to do nothing. Have you tried adding some message at the very beginning of the app to make sure some code inside of it is/is not being hit?

livarcocc avatar Sep 20 '18 17:09 livarcocc

@livarcocc I did run following command: dotnet publish abc.csproj -r rhel.7-x64 It has worked for me. I was checking the wrong folder actually. Silly mistake. JSON file is correct as my previous objects are having similar JSON file and previous objects were running fine on Linux.

Thanks

ms0713 avatar Sep 27 '18 04:09 ms0713