1
votes

Hoping you can help me with this strange error. I've developed a very simple ASP.NET Core web application on windows 10 using visual studio code. I've run dotnet publish command and tried running the application from under the "publish" folder, which was created. I used the command dotnet Project.dll. It worked and I was able to browse localhost on port 5000 to view the application.

I then zipped the content of the "publish" folder and copied to a linux VM running Ubuntu 16.04, but I've received the following strange error on the command line when I try to execute the application using: dotnet Project.dll. I was using ssh to remote to linux vm and execute the command above.

ERROR MESSAGE SEEN ON COMMAND LINE:

Error: assembly specified in the dependencies manifest was not found -- package: 'System.Net.NetworkInformation', version: '4.1.0', path: 'runtimes/linux/lib/netstandard1.3/System.Net.NetworkInformation.dll'


I used the following link to install .net core on the vm: https://www.microsoft.com/net/core#ubuntu

When I do dotnet --version on windows I see: 1.0.0-preview2-003121 When I do dotnet --verison on Ubuntu I see: 1.0.0-preview2-003131

Any help to resolve the above error would be greatly appreciated!

Here is the project.json file:

{
    "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",    
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Configuration":"1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "MailKit": "1.8.1"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "web.config", 
      "appsettings.json"
    ]
  },

  "tooling": {
    "defaultNamespace": "Company.Website"
  }
}
2
Try instead publish folder copy to VM with Ubuntu, project folder and run command from main folder of project. Try follow this tutorial hanselman.com/blog/…M. Wiśnicki

2 Answers

1
votes

You have created an portable app, but did not installed .NET Core runtime on Linux. When you create a portable app, you have to install the runtime.

If you create a self-contained application, then you don't need to install the runtime.

Basically when you use

"Microsoft.NETCore.App": {
  "version": "1.0.0",
  "type": "platform"
}

It's platform/runtime dependent and you need a runtime installed but have smaller deployment file size.

If you remove the "type": "platform", then its a self-contained and you need additionally add

 "runtimes": {
   "win10-x64": {},
   "osx.10.10-x64": {}
 }

to your project.json with all platforms you want to be able to deploy. With the above you can't run it on Linux.

After that you can dotnet build/publish to build/bundle/publish it. You will get one folder per platform above.

Source: http://docs.microsoft.com/en-us/dotnet/articles/core/deploying/index

0
votes

I found an answer on GitHub for .NET. I added these lines to the project.json dependencies:

"runtime.linux.System.Net.NetworkInformation": "4.1.0-beta-*",
"runtime.unix.System.Net.Security": "4.0.0-beta-23516"

This fixed my Ubuntu publishing problem. I did not have any Windows problems continuing to debug in IIS Express or Visual Studio with these additional dependencies.