Ubuntu Linux上的dotnet核心使用asp.net MVC和EF MySQL錯誤NU1001:無法恢復MySql.Data.EntityFrameworkCore

asp.net-core entity-framework-core linux mysql ubuntu-server

我已經構建了一個簡單,扁平的dotnet核心MVC應用程序,我希望看到它在Linux上運行。它使用EF從mysql表中提取一些記錄並在視圖中顯示它們。這一切都在我的主機(Win10)上構建和運行,但不會在Ubuntu VM中進行測試

在我執行“dotnet restore”後,我在“dotnet build”或“dotnet run”中收到以下錯誤:

項目CoreCrossPlatformFlat(.NETCoreApp,Version = v1.0)將被編譯,因為自上次構建以來,CLI的版本或位數發生了變化,為.NETCoreApp編譯CoreCrossPlatformFlat,版本= v1.0 / opt / dotnet / corecrossplatform / src / CoreCrossPlatformFlat / project.json(25,52):錯誤NU1001:無法解析依賴項MySql.Data.EntityFrameworkCore> = 7.0.4-IR-191。

編譯失敗。 0警告1錯誤

僅供參考:這是“dotnet --info”報導的內容:

.NET命令行工具(1.0.0-preview2-003121)

產品信息:版本:1.0.0-preview2-003121提交SHA-1哈希:1e9d529bc5

運行時環境:OS名稱:ubuntu OS版本:16.04 OS平台:Linux RID:ubuntu.16.04-x64

對於VM,我按照以下說明操作:

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

project.json看起來像這樣:

{
  "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%" ]
  }
}

如果有幫助的話,這裡是解決方案的拉鍊: https//s3.amazonaws.com/kilonova-public/code/CoreCrossPlatformFlat.zip

熱門答案

今天遇到了同樣的問題。請嘗試刪除除project.json文件和項目文件夾中的所有.cs文件之外的所有文件和文件夾。然後dotnet恢復和dotnet運行。這個對我有用。 :)



Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
這個KB合法嗎? 是的,了解原因