0

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"
    ]
  }
}
2
  • 1
    Lovely how all of you downvote, yet none leaves a comment. Commented Dec 23, 2016 at 15:15
  • 1
    Baklap4, unfortunately you are right. If a post is not to my liking to the point that I downvote it I always leave a comment to allow the author to improve the post and if I see significant improvement I always revoke downvotes. Unfortunately I see there are some people here who are not elegant-enough to do so. At one place where I am sure my answer was correct, it was downvoted twice. I have asked for the reason four times, since they always censor that comment there. Commented Dec 23, 2016 at 17:57

3 Answers 3

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer solved my problem, thanks. As linux is case sensitive, it doesn't find IR31 if he folder is named ir31. I opened project.lock.json, replaced all instances of IR31 to ir31, and now dotnet build does not throw the error anymore.
If I may: you seem to understand asp.net core and how it interacts with linux, so I wonder if you know the answer to this seemingly basic question of mine.
1

Recently I had a similar problem with another dependency. After a long process of torture I realized that the dependency need to be installed via an installer, or if that is not possible in your case, then you can copy. Here you can get the package and information if this is not installed on the server yet: https://www.nuget.org/packages/MySql.Data.EntityFrameworkCore/7.0.6-IR31.

At this folder

c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\

you have several folders with .NET Frameworks. You need to make sure that the dll and xml files you need are there.

Comments

0

I ran into exactly the same issue with the same package (works fine on my Windows machine locally, fails when Jenkins runs dotnet restore and dotnet build in a docker container). Following on from Baklap4's answer, as part of the dockerfile I added the following line

RUN echo "{ \"packages\": \"packages\" }" >> global.json

in combination with

RUN dotnet restore --packages "packages"

resulting in it restoring all packages into the container's "packages" folder, and all projects within knowing to look for them in that folder. Once I know where the packages are I can run

RUN mv MySql.Data/7.0.6-ir31 MySql.Data/7.0.6-IR31
RUN mv MySql.Data.EntityFrameworkCore/7.0.6-ir31   MySql.Data.EntityFrameworkCore/7.0.6-IR31

to rename those folders to uppercase.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.