dotnet core on Ubuntu Linux using asp.net MVC and EF MySQL error NU1001: cannot restore MySql.Data.EntityFrameworkCore

拜拜、爱过 提交于 2019-12-10 18:41:29

问题


I've built a simple, flat dotnet core MVC app that I'd like to see running on Linux. It uses EF to pull a few records from a mysql table and display them in a view. It all builds and runs on my host (Win10) but will not in the Ubuntu VM I've spun up to test with

After I do a "dotnet restore", I get the following error with "dotnet build" or "dotnet run":

Project CoreCrossPlatformFlat (.NETCoreApp,Version=v1.0) will be compiled because the version or bitness of the CLI changed since the last build Compiling CoreCrossPlatformFlat for .NETCoreApp,Version=v1.0 /opt/dotnet/corecrossplatform/src/CoreCrossPlatformFlat/project.json(25,52): error NU1001: The dependency MySql.Data.EntityFrameworkCore >= 7.0.4-IR-191 could not be resolved.

Compilation failed. 0 Warning(s) 1 Error(s)

FYI: Here's what "dotnet --info" reports:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information: Version: 1.0.0-preview2-003121 Commit SHA-1 hash: 1e9d529bc5

Runtime Environment: OS Name: ubuntu OS Version: 16.04 OS Platform: Linux RID: ubuntu.16.04-x64

For the VM, I followed these instructions:

https://www.microsoft.com/net/core#ubuntu

The project.json looks like so:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0",
    "Microsoft.EntityFrameworkCore": "1.0.0",
    "MySql.Data.Core": "7.0.4-IR-191",
    "MySql.Data.EntityFrameworkCore": "7.0.4-IR-191"
  },

  "tools": {
    "BundlerMinifier.Core": "2.0.238",
    "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final",
    "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",
      "Areas/**/Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Here's a zip of the solution if that helps: https://s3.amazonaws.com/kilonova-public/code/CoreCrossPlatformFlat.zip


回答1:


Encountered the same problem today. Please try deleting all files and folders except the project.json file and all the .cs files in your project folder. Then dotnet restore and dotnet run. It works for me. : )



来源:https://stackoverflow.com/questions/39330191/dotnet-core-on-ubuntu-linux-using-asp-net-mvc-and-ef-mysql-error-nu1001-cannot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!