MSBuild could not resolve the reference from restored nuget package

MSBuild could not resolve restored nuget package reference

Hi guys! i have a problem building a class library project with 3.5 .NET Framework, somebady can help me please?
this is my .gitlab-ci.yml:

image: mono:latest

stages:
  - package_entities
  - package_interface

package_entities:
  stage: package_entities
  script:
    - nuget sources add -Name  gitlab -source "$CI_SERVER_URL/api/v4/projects/2xxxx0/packages/nuget/index.json"  -username gitlab-ci-token  -password $CI_JOB_TOKEN -StorePasswordInClearText
    - nuget restore
    - nuget pack Entities/Entities.csproj -Build -Symbols -Properties Configuration=Release
    - nuget push "*.nupkg" -Source gitlab
  only:
    - master

package_interface:
  stage: package_interface
  script:
    - nuget sources add -Name  gitlab -source "$CI_SERVER_URL/api/v4/projects/2xxx0/packages/nuget/index.json"  -username gitlab-ci-token  -password $CI_JOB_TOKEN -StorePasswordInClearText
    - nuget restore
    - nuget pack dummy_Interface/dummy_Interface.csproj -Build -Symbols -Properties Configuration=Release
    - nuget push "*.nupkg" -Source gitlab
  only:
    - master
  • the first stage is successfully completed, the second throws me the following output:

$ nuget sources add -Name gitlab -source “$CI_SERVER_URL/api/v4/projects/25xxxx40/packages/nuget/index.json” -username gitlab-ci-token -password CI_JOB_TOKEN -StorePasswordInClearText Package source with Name: gitlabPro added successfully. nuget restore
MSBuild auto-detection: using msbuild version ‘15.0’ from ‘/usr/lib/mono/msbuild/15.0/bin’.
Restoring NuGet package Entities.1.0.0.
GET https://api.nuget.org/v3-flatcontainer/entities/1.0.0/entities.1.0.0.nupkg*
OK https://api.nuget.org/v3-flatcontainer/entities/1.0.0/entities.1.0.0.nupkg 18ms
Installing Entities 1.0.0.
GET https://gitlab.com/api/v4/projects/25xxxx0/packages/nuget/download/entities/1.0.0/entities.1.0.0.nupkg
Adding package ‘Entities.1.0.0’ to folder ‘/builds/dummycomponents/dummy-interface/packages’
Added package ‘Entities.1.0.0’ to folder ‘/builds/dummycomponents/dummy-interface/packages’
Restoring NuGet package MySql.Data.6.9.12.
GET https://api.nuget.org/v3-flatcontainer/mysql.data/6.9.12/mysql.data.6.9.12.nupkg
GET https://gitlab.com/api/v4/projects/25xxx40/packages/nuget/download/mysql.data/6.9.12/mysql.data.6.9.12.nupkg
OK https://api.nuget.org/v3-flatcontainer/mysql.data/6.9.12/mysql.data.6.9.12.nupkg 16ms
Installing MySql.Data 6.9.12.
Adding package ‘MySql.Data.6.9.12’ to folder ‘/builds/dummycomponents/dummy-interface/packages’
Added package ‘MySql.Data.6.9.12’ to folder ‘/builds/dummycomponents/dummy-interface/packages’
Restoring NuGet package Utilities.3.5.0.
GET https://api.nuget.org/v3-flatcontainer/utilities/3.5.0/utilities.3.5.0.nupkg
GET https://gitlab.com/api/v4/projects/25xxxx40/packages/nuget/download/utilities/3.5.0/utilities.3.5.0.nupkg
NotFound https://api.nuget.org/v3-flatcontainer/utilities/3.5.0/utilities.3.5.0.nupkg 87ms
OK https://gitlab.com/api/v4/projects/257xxxx40/packages/nuget/download/utilities/3.5.0/utilities.3.5.0.nupkg 421ms
Installing Utilities 3.5.0.
Adding package ‘Utilities.3.5.0’ to folder ‘/builds/dummycomponents/dummy-interface/packages’
Added package ‘Utilities.3.5.0’ to folder ‘/builds/dummycomponents/dummy-interface/packages’
NuGet Config files used:
/root/.config/NuGet/NuGet.Config
Feeds used:
https://api.nuget.org/v3/index.json
https://gitlab.com/api/v4/projects/257*40/packages/nuget/index.json
Installed:
3 package(s) to packages.config projects

  • packages are apparently restored well, but when start to build it fails:

$ nuget pack dummy_Interface/dummy_Interface.csproj -Build -Symbols -Properties Configuration=Release
Attempting to build package from ‘dummy_Interface.csproj’.
MSBuild auto-detection: using msbuild version ‘15.0’ from ‘/usr/lib/mono/msbuild/15.0/bin’.
Building project ‘/builds/dummycomponents/dummy-interface/dummy_Interface/dummy_Interface.csproj’ for target framework ‘.NETFramework,Version=v3.5’.
Microsoft (R) Build Engine version 16.6.0 for Mono
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 04/09/2021 19:35:41.
Project “/builds/dummycomponents/dummy-interface/dummy_Interface/dummy_Interface.csproj” on node 1 (default targets).
PrepareForBuild:
Creating directory “bin/Release/”.
Creating directory “obj/Release/”.
ResolveAssemblyReferences:
Primary reference “Entities”.
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly “Entities”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/builds/dummycomponents/dummy-interface/dummy_Interface/dummy_Interface.csproj]
For SearchPath “{HintPathFromItem}”.
Considered “/builds/dummycomponents/dummy-interface/packages/Entities.1.0.0/lib/net35/Entities.dll”, but it didn’t exist.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/Entities.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/Entities.dll”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/Entities.exe”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/Entities.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/Entities.dll”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/Entities.exe”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/Entities.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/Entities.dll”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/Entities.exe”, but it didn’t exist.
For SearchPath “{GAC}”.
Considered “Entities”, which was not found in the GAC.
For SearchPath “{RawFileName}”.
Considered treating “Entities” as a file name, but it didn’t exist.
For SearchPath “bin/Release/”.
Considered “bin/Release/Entities.winmd”, but it didn’t exist.
Considered “bin/Release/Entities.dll”, but it didn’t exist.
Considered “bin/Release/Entities.exe”, but it didn’t exist.
Primary reference “MySql.Data”.
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly “MySql.Data”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/builds/dummycomponents/dummy-interface/dummy_Interface/dummy_Interface.csproj]
For SearchPath “{HintPathFromItem}”.
Considered “/builds/dummycomponents/Dependencies/MySql.Data.dll”, but it didn’t exist.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/MySql.Data.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/MySql.Data.dll”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/MySql.Data.exe”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/MySql.Data.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/MySql.Data.dll”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/MySql.Data.exe”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/MySql.Data.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/MySql.Data.dll”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/MySql.Data.exe”, but it didn’t exist.
For SearchPath “{GAC}”.
Considered “MySql.Data”, which was not found in the GAC.
For SearchPath “{RawFileName}”.
Considered treating “MySql.Data” as a file name, but it didn’t exist.
For SearchPath “bin/Release/”.
Considered “bin/Release/MySql.Data.winmd”, but it didn’t exist.
Considered “bin/Release/MySql.Data.dll”, but it didn’t exist.
Considered “bin/Release/MySql.Data.exe”, but it didn’t exist.
Primary reference “Utilities”.
/usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets(2101,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly “Utilities”. Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/builds/dummycomponents/dummy-interface/dummy_Interface/dummy_Interface.csproj]
For SearchPath “{HintPathFromItem}”.
Considered “/builds/dummycomponents/dummy-interface/Dependencias/Utilities.dll”, but it didn’t exist.
For SearchPath “{TargetFrameworkDirectory}”.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/Utilities.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/Utilities.dll”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.5/Utilities.exe”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/Utilities.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/Utilities.dll”, but it didn’t exist.
Considered “/usr/lib/mono/xbuild-frameworks/.NETFramework/v3.0/Utilities.exe”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/Utilities.winmd”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/Utilities.dll”, but it didn’t exist.
Considered “/usr/lib/mono/2.0-api/Utilities.exe”, but it didn’t exist.
For SearchPath “{GAC}”.
Considered “Utilities”, which was not found in the GAC.
For SearchPath “{RawFileName}”.
Considered treating “Utilities” as a file name, but it didn’t exist.
For SearchPath “bin/Release/”.
Considered “bin/Release/Utilities.winmd”, but it didn’t exist.
Considered “bin/Release/Utilities.dll”, but it didn’t exist.
Considered “bin/Release/Utilities.exe”, but it didn’t exist.

this is so weird, specially because the restore task return the output “Added package ‘MySql.Data.6.9.12’ to folder ‘/builds/dummycomponents/dummy-interface/packages’”

Thanks for taking the time to read all this mess :blush:

SOLVED!
the problem here is the compability between MySql.Data and 3.5 .NET Framework, that broke the compilation. in my case using MySql.Data version 6.8.7.0 solved the problem. Thanks