Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET CLI how to run app after publish on Linux

I spent ~4 hours investigation and still can't find out how to run published application ( dotnet publish )

Now I can download sources to my remote machine, then call dotnet build and dotnet run - then my app runs as intended. But I want to publish just DLL's (or *.so ?) to my VPS without source files.

What official docs says? To define command in project.json

"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel --server.urls http://unix:/var/aspnet/HelloMVC/kestrel.sock",
}

But it is obsolette, isn't it?

What about default samples?

In default VS2015 sample solution they use publish-iis, Full .NET framework and IIS server, but there is nothing about deployment on linux.

postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]

Here is my dotnet info

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.10586
 OS Platform: Windows
 RID:         win10-x64

.NET Core RC2

like image 202
Toddams Avatar asked May 22 '16 16:05

Toddams


People also ask

How do I run a dotnet published app?

When you publish your app as an FDD, a <PROJECT-NAME>. dll file is created in the ./bin/<BUILD-CONFIGURATION>/<TFM>/publish/ folder. To run your app, navigate to the output folder and use the dotnet <PROJECT-NAME>. dll command.

Can you run a .NET Framework app on Linux?

Thanks to . NET Core being open source, you can also install and use the . NET Framework on your Linux machine. Even better: An application created on any system can run on any other system, regardless of operating system.


1 Answers

Do the following steps (starting from a RC2 portable application; the normal one):

  1. Remove the "type": "platform" annotation from all your dependencies (so it is actuall self-contained and no longer rely on a installed .NET Core platform).

  2. Add a node runtimes to your project.json (so NuGet is able to pull the necessary platform parts to your local machine)

    Sample:

    "runtimes": {
      "osx.10.11-x64": { },
      "win10-x64": { },
      "ubuntu.14.04-x64": { }
    }
    
  3. dotnet restore (to make sure the new runtimes are locally available).

  4. dotnet build (if not already done for the portable app)

  5. dotnet publish -r ubuntu.14.04-x64 (to bundle it up)

  6. See the result directory with a platform specific dotnet command able to run the app.

I followed the steps found in the .NET Core documentation.

like image 94
Thomas Avatar answered Sep 18 '22 13:09

Thomas