MySQL - > .NET Core Dependency错误(MySql.Data) [英] MySQL -> .NET Core Dependency error (MySql.Data)

查看:159
本文介绍了MySQL - > .NET Core Dependency错误(MySql.Data)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试通过.NET Core连接到MySQL数据库。
一切工作在本地,但在我们的服务器上,gitlab-ci正在运行,它失败了。因此无法构建。



抛出的错误:错误NU1001:依赖关系MySql.Data> = 7.0.6-IR31无法解析。这是非常奇怪的,因为它适用于我们本地的机器,而不是在Docker内运行的CI。



运行 dotnet恢复 dotnet run 本地工作。 dotnet restore 在服务器上也可以使用,您可以看到安装了MySql.Data包。然而,当运行单元测试时,它会因为依赖关系无法解决而中断。可能没有linux兼容?



我们做错了什么?



project.json文件:

  {
dependencies:{
Microsoft.NETCore.App:{
:1.0.0,
type:platform
},
Microsoft.AspNetCore.Mvc:1.0.0,
Microsoft。 AspNetCore.Server.Kestrel:1.0.0,
Microsoft.AspNetCore.Diagnostics:1.0.0,
Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore:1.0.0 ,
Microsoft.Extensions.Configuration:1.0.0,
Microsoft.Extensions.Configuration.CommandLine:1.0.0,
Microsoft.Extensions.Configuration。 Binder:1.0.0,
Microsoft.Extensions.Configuration.EnvironmentVariables:1.0.0,
Microsoft.Extensions.Configuration.Json:1.0.0,
Microsoft.Extensions.Configuration.FileExtensions: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.EntityFrameworkCore:1.0.0,
DotNetAirbrake:1.0.33,
Geitenbelang.AnimalManager.Api.Models:1.0.0- *,
Geitenbelang.AnimalManager.Api.Database:1.0.0- *,
AutoMapper:5.1.1,
MySql.Data.EntityFrameworkCore:7.0.6 -IR31
},

框架:{
netcoreapp1.0:{}
},

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

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

publishOptions:{
include:[
wwwroot,
Views,
Areas / ** / Views,
appsettings.json,
web.config
]
}
}


解决方案

除了Lajos Arpad,我很好奇,调查了一下。在Windows上安装依赖项似乎在以下路径下保存nuget软件包:
packages\MySql.Data.EntityFrameworkCore\7.0.6-IR31 / p>

在Linux上,另一方面,它在此路径上安装软件包:
packages\MySql.Data.EntityFrameworkCore\7.0。 6-ir31



正如在 MySql.Data.EntityFrameworkCore 的nuspec文件中声明的那样该版本被定义为 7.0.6-IR31



当我使用命令 dotnet restore 我可以得出结论 dotnet restore 正在做一些关于恢复的奇怪的事情。
将Linux上的nuspec文件中的版本更改为 7.0.6-ir31 解决了我的问题。
由于这是一个错误(不重要的版本),我将填写一个错误报告。



链接到bugreport: https://github.com/dotnet/cli/issues/5155


We're trying to connect to a MySQL database through .NET Core. Everything works local but on our server where gitlab-ci is running it fails building. Therefore failing the build.

The error thrown: error NU1001: The dependency MySql.Data >= 7.0.6-IR31 could not be resolved. This is weird since it works on our local machines, but not on the CI running within docker.

running dotnet restore and dotnet run locally works. dotnet restore works also on the server and you can see the MySql.Data package is installed. Yet when running the unittests it breaks because the dependency could not be resolved. Maybe not linux compatible?

What are we doing wrong?

the project.json file:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0",
    "Microsoft.Extensions.Configuration": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Configuration.Binder": "1.0.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "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.EntityFrameworkCore": "1.0.0",
    "DotNetAirbrake": "1.0.33",
    "Geitenbelang.AnimalManager.Api.Models": "1.0.0-*",
    "Geitenbelang.AnimalManager.Api.Database": "1.0.0-*",
    "AutoMapper": "5.1.1",
    "MySql.Data.EntityFrameworkCore": "7.0.6-IR31"
  },

  "frameworks": {
    "netcoreapp1.0": {}
  },

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

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

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

解决方案

In addition to Lajos Arpad i got curious and investigated a bit. It seems when installing dependencies on Windows it save the nuget package under the following path: packages\MySql.Data.EntityFrameworkCore\7.0.6-IR31

On Linux on the other hand it installs the package on this path: packages\MySql.Data.EntityFrameworkCore\7.0.6-ir31

As declared in the nuspec file of MySql.Data.EntityFrameworkCore the version is defined as 7.0.6-IR31

As i restore the packages with the command dotnet restore can I conclude dotnet restore is doing some weird shit regarding restoring. Changing the version in the nuspec file on Linux to 7.0.6-ir31 solved my problem. As this is a bug (not respecting capitals in version) i'm going to fill out a bug report.

Link to bugreport: https://github.com/dotnet/cli/issues/5155

这篇关于MySQL - > .NET Core Dependency错误(MySql.Data)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆