Reputation: 491
I had an app I was developing in asp.net 4.5 and I wanted to move it to asp.net core and run on linux server (ubuntu).
I've been having a number of challanges and unfortunately current documentation is not helpful.
so...
How should I package the app?
The tech docs suggest building with the following command
dnu publish --runtime dnx-coreclr-linux-x64.1.0.0-rc1-update1
However I tried this on my local machine and it didn't have option to deploy linux version. When I run on server it comes up with a number of problems (covered later). So should I do this on server or get working on local machine.
NB: I read in another stack overflow question that as long as its coreclr it doesn't matter whether its win or linux?
I imagine after this is answered more questions will emerge..I've had so many issues with Core I'm wondering whether anybody has actually manged to deploy on app to Linux environment!
Any help would be greatly appreciated!
Update
To provide further information current runtimes on local machine are...
Active Version Runtime Architecture Location Alias
------ ------- ------- ------------ -------- -----
1.0.0-beta5 clr x64 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 clr x86 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 coreclr x64 C:\Users\Alex.dnx\runtimes
1.0.0-beta5 coreclr x86 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 clr x64 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 clr x86 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 coreclr x64 C:\Users\Alex.dnx\runtimes
1.0.0-rc1-update1 coreclr x86 C:\Users\Alex.dnx\runtimes
* 1.0.0-rc1-update2 clr x86 C:\Users\Alex.dnx\runtimes default
1.0.0-rc1-update2 coreclr x86 C:\Users\Alex.dnx\runtimes
I want to compile it as coreclr linux....however when I run the dnu publish command above it says runtime doesn't exist even though I update coreclr from nuget?
Do I need to specify an OS (linux or windows) when I build it or will a single published app run on both if its coreclr?
This runs fine when imported into Azure but doesn't work when deployed to linux
Upvotes: 1
Views: 1421
Reputation: 82326
OK, here's how to:
Install Visual Studio 2017 (with .NET Core)
Create your project, and get it to compile on Windows
Once it compiles and runs, make sure you can publish it from Visual Studio
Once you can publish it from Visual Studio, close Visual Studio and do the following
open cmd.exe (Windows-Key + R)
cd "directory of your .sln file"
dotnet restore -r ubuntu.16.04-x64
dotnet build -r ubuntu.16.04-x64
dotnet publish -f netcoreapp1.1 -c Release -r ubuntu.16.04-x64
Your application should now be in folder bin/publish
A list of RIDs (-r) can be obtained here and here.
If you want to develop on Linux, run
apt-get install dotnet-dev-1.0.1
and the dotnet-utility should run on Linux.
Note that if you get
C:\Program Files\dotnet\sdk\1.0.0\Microsoft.Common.CurrentVersion.targets(2865,5): error MSB3554: Cannot write to the output file "C:\path\to\your\project\obj\Debug\netcoreapp1.1\YOUR_APP.Properties.Resources.resources". Positive number required.
Build FAILED.
when you run the build or publish command, just run the command again.
Upvotes: 2