syncfusion.compression.base cannot be downloaded because it is not compatible with any project in the solution - visual-studio

Hi, I was working on a solution using Visual Studio. While restoring the Nuget, i got the error "syncfusion.compression.base" is missing. When I tried downloading the Nuget, it gave the message as shown in screenshot. What shall I do now?

When I tried downloading the Nuget, it gave the message as shown in screenshot. What shall I do now?
You need to figure out which project installed the package before in your solution. You can check it with the package.config file.
After download the package syncfusion.compression.base from nuget.org, we could to know this package only have one assembly for .NET framework 46:
After you figure out which project installed this package, you should check the project type and target framework, make sure the target framework is .NET 46 and above.
Besides, if can not find this package in the package.config or project.json, you may need to check if your project file contains HintPath for this package, like:
<Reference Include="Syncfusion.Compression.Base, Version=15.2460.0.40, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89, processorArchitecture=MSIL">
<HintPath>..\packages\Syncfusion.Compression.Base.15.2460.40\lib\net46\Syncfusion.Compression.Base.dll</HintPath>
<Private>True</Private>
</Reference>
To determine whether the package is what you need, if not, you need delete it in the project file and delete the package in the packages folder.

Related

nuget.config ignores dependencies of dependencies (sub-dependencies)

I have a nuget.config for my project and have specified a repositoryPath. I also have specified the globalPackagesFolder.
<config>
<add key="globalPackagesFolder" value="c:\p" />
<add key="repositoryPath" value="c:\p" />
</config>
Now I want to install a third party package to my project. This package is located correctly at my specified path.
When I try to install another package, that has a dependency to System.Net.Http which has other sub-dependencies, nuget is not able to install this package, because the path is too long.
The direct dependecies are located in my specified repositoryPath from the nuget.config. The problem is, that sub-dependencies are not located at this path. A file search in this repositories resulted in no matches.
The only reason I specified a repositoryPath in nuget.config is that I wanted to move the sub-dependencies to another folder, because otherwise the path is too long and nuget can't install the package. This is not a problem for my co-workers.
How can I change this behavior?
If this is not possible, is there another solution to my problem?
A co-worker sugested to shorten my Windows login, but this is not a solution. I also can't shorten our Teamcity user login name.
The package I try to install is developed by my company. So if I have to change settings in the package, this is not a problem.
I tried with Visual Studio 2017 Pro and Enterprise with Nuget 4.6.0 and Visual Studio 2019 RC with Nuget 5.0.0.
Target Framework is .NET Core 2.1
When I add the package System.Net.Http to my project manualy and install the package, there is no problem, but i would rather don't do this, unless there is no other solution.
Edit:
To clarify the situation: If I install Package A that has a dependency to package B and B has a dependency to Package C, Package A is in my specified Path, but B and C are not. I don't even know, where Package B and C are located.
nuget.config ignores dependencies of dependencies (sub-dependencies)
This is the correct behavior for .NET Core project.
In dotnet core, or projects that use PackageReference, reference to only the immediate dependencies are listed and only download the immediate dependencies to the package cache.
That is the reason why you install Package A that has a dependency to package B and B has a dependency to Package C, Package A is show up in your project file like:
<PackageReference Include="PackageA" Version="1.0.0" />
and cache in your specified Path, but B and C are not.
This is a one of the biggest advantages of PackageReference where we don't clutter the project file with gazillion dependencies which the consumer probably doesn't care about. Install your nuget package to a project, navigate to the project_root/obj/project.assets.json and open this json, you'd see your package listed along with its dependencies. If you see your intended dependencies here, it validates that package is authored correctly. But NuGet will not restore the dependencies to the packages cache unless you install these dependencies directly.
Hope this helps.

Xamarin.Android: Package XX is not compatible with monoandroid81 (MonoAndroid,Version=v8.1)

I encounter a stranger behavior with a Xamarin.Android project in Visual Studio on Windows.
I've created a new Android blank project, and I try ton install the NuGet package "AForge" (a mathematics library), but I get the following error message:
Package AForge 2.2.5 is not compatible with monoandroid81
(MonoAndroid,Version=v8.1).
I've already tried to re create several projects, after having relaunched Visual Studio and the computer, but the problem is still the same.
However, if I do the same thing on Mac, through Visual Studio for Mac, I don't encounter the same problem: the package is well installed.
In add, I can see in the package.config file, that the package il well related to monodroid81:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AForge" version="2.2.5" targetFramework="monoandroid81" />
</packages>
Would you have any explanation about this issue?
Update: new issue
Hi #Leo Liu-MSFT, I come back to you as I encounter an new issue. The dll copy works fine locally, but I get an error on AppCenter:
CoreCompile:
/Library/Frameworks/Mono.framework/Versions/5.10.1/lib/mono/4.5/csc.exe
/noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4
/define:DEBUG;TRACE;XAMARIN_ANDROID_v1_0;MOBILE;ANDROID;ANDROID_1;ANDROID_2;ANDROID_3;ANDROID_4;ANDROID_5;ANDROID_6;ANDROID_7;ANDROID_8;ANDROID_9;ANDROID_10;ANDROID_11;ANDROID_12;ANDROID_13;ANDROID_14;ANDROID_15;ANDROID_16;ANDROID_17;ANDROID_18;ANDROID_19;ANDROID_20;ANDROID_21;ANDROID_22;ANDROID_23;ANDROID_24;ANDROID_25;ANDROID_26;ANDROID_27
/reference:/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/Java.Interop.dll
/reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.Android.Bindings.dll
/reference:/Users/vsts/.nuget/packages/microsoft.appcenter.analytics/1.7.0/lib/MonoAndroid403/Microsoft.AppCenter.Analytics.dll
/reference:/Users/vsts/.nuget/packages/...
Services/AudioService.cs(8,7): error CS0246: The type or namespace
name 'AForge' could not be found (are you missing a using directive or
an assembly reference?)
[/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj] Done
Building Project
"/Users/vsts/agent/2.136.1/work/1/s/XxxApp/XxxApp.csproj"
(PackageForAndroid target(s)) -- FAILED.
So I tried your suggestion, but I get an error when I try to save the package:
a local file header is corrupted'
Would you have another suggestion?
Would you have any explanation about this issue?
You can get the official document here:
Description: With PackageReference, assemblies present at the root of
lib folder without a target framework specific sub-folder are ignored.
NuGet looks for a sub-folder matching the target framework moniker
(TFM) corresponding to the project’s target framework and installs the
matching assemblies into the project.
In this case, NuGet will consider installing this package to the .NET Framework, which is not compatible with monoandroid81. Then you will that error "Package AForge 2.2.5 is not compatible with monoandroid81".
To resolve this issue, the best way is contact the author of the AForge NuGet package to update this package, or you can also add reference dll file directly to your project.
Besides, if you still want to use nuget to manager this package, I would like provide you a workaround to resolve this issue:
Download this nuget package from nuget.org.
Copy the download package, rename it with .zip, like aforge.2.2.5 - Copy.nupkg.zip, then unzip it.
Open the package aforge.2.2.5.nupkg with NuGet Package Explorer(Get it from Microsoft store), add a new folder MonoAndroid81 under the lib node, add exists file AForge.dll and AForge.xml from the copy folder aforge.2.2.5 - Copy.nupkg.zip, save this nuget package.
Add this new create nuget package to the nuget local feed, then add this nuget package to the project. Do not forget delete the nuget package cache in the C:\Users\<UserName>\.nuget\packages\aforge before you add the package.
Hope this helps.

NuGet package reference & version

I tried crawling through the documentation for NuGet and Visual Studio but did not find an exact answer for my question. Also am new to using NuGet.
If I have a packages.config like below:
<packages>
<package id="xxx.SomePackage" version="1.0.1" targetFramework="net452" />
</packages>
And a similar reference in my .csproj for the project:
<Reference Include="xxx.SomePackage, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\xxx.SomePackage.1.0.1\lib\net45\xxx.dll</HintPath>
<Private>True</Private>
</Reference>
Suppose I have a newer version which I want the projects to use namely 1.0.2, should I manually change each csproj/packages.config reference to point to that version or is NuGet smart enough to get and apply only the latest version to my projects ? I have a lot of projects so it's a pain to change for each one.
Note: I read about using SpecificVersion: False. Is that something I can use ?
Note: I also read about "Update-Package -reinstall". Is this the best and preferred method for scenarios like mine ?
should I manually change each csproj/packages.config reference to point to that version or is NuGet smart enough to get and apply only the latest version to my projects ? I have a lot of projects so it's a pain to change for each one.'
No, you don not need to manually change each csproj/packages.config reference to point to that version. NuGet smart enough to get and apply only the latest version to your projects.
You can use the command line Update-Package -Id <package_name> -Version 1.0.2 in the Package Manager Console, without specifying any particular project, Update-Package affects all projects in a solution. See update-package for more detail info.
Alternatively, you can also update all projects via Manager NuGet Packages for Solution. Right click your solution (not project), select Manager NuGet Packages for Solution, switch to Updates tab, choose the package you need to upgrade, then select the projects you want to update the package:
Besides, Update-Package -reinstall is used to reinstall packages, using this command is much easier than removing a package and then trying to locate the same package in the NuGet gallery with the same version. So this command would not update the version of the package.
Hope this helps.

Is NuGet automatic package restore in Visual Studio 2015 a fairy tale/mythical beast?

I have been trying to figure out why automatic package restore in Visual Studio 2015 doesn't work.
As I understand it there is nothing to do but check a couple of settings. When you build, it looks for missing packages and downloads them automatically.
I have a solution that has 15 individual projects. The majority of them will not compile because of "missing packages".
I do not have any of the legacy NuGet (.nuget folder etc.) in any of these projects and I have the latest and greatest version of NuGet.
Visual Studio simply will not download the missing files. I deleted the solution package folder and it does re-create and download all of the packages when I build, but each individual project still shows missing references.
If I go to the package manager console and issue a
Update-Package -reinstall
then the packages download and everything works. I'm just wonder why it doesn't do this automatically.
It's supposed to right?
NuGet Restore only restores files in the packages directory, but does not restore files inside your project or modify your project.
For example, if there has a package will add some reference dlls or add some content files into your project. After deleting these reference dlls and content files from your project, it will not be added when restoring this package. This will cause the your project could not find the missing pacakges when compile.
So we need use "Update-Package -reinstall" command to force reinstall the package references and content files into project.
Update the example for sharing projects in a team:
Following is my solution structure, the CommDLL project installed some NuGet packages and entire solution is managed by a source control.
I download this solution on another machine from source control use another user account and install another NuGet packages into the CommDLL project. Then use some content from the new installed package and build the project successful. Please make sure the package dlls has been added into your project and it has been set the correct HintPath in .csproj file.
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
Next, I check in this modified project into the source control. Please make sure you the .csproj file and packages.config file are checked in.
Now I get the latest version on another machine to get the modified content. After check out the latest version from source control, the package references are shown with a warning because the project is not compiled, which means the packages are not restored. Please rebuild this project, it will restore the packages for your project (make sure your Visual Studio 2015 has enable "Allow NuGet to download missing packages" and "Automatically check for missing packages during build in Visual Studio" before rebuild this project).

Visual Studio 2015 can't find nuget package references and DLLs in packages folder

I've been given a C# project by someone else. I opened the project and tried to install all the Nuget packages by doing a Update-Package -reinstall.
It downloaded all the packages in the packages folder.
/Projects
/WebApiTest (root folder)
WebApiTest.csproj
WebApiTest.sln
/packages (packages are loaded in this folder)
But the entire project still says that it's missing all the references. I editted the csproj file to see where it tries to load the packages from, and that is:
<ItemGroup>
<Reference Include="Antlr3.Runtime">
<HintPath>packages\Antlr.3.4.1.9004\lib\Antlr3.Runtime.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="EntityFramework.SqlServer">
<HintPath>packages\EntityFramework.6.1.3\lib\net45\EntityFramework.SqlServer.dll</HintPath>
<Private>True</Private>
</Reference>
... etc.
So I assume it starts looking in the same directory as the csproj file is in. In that same directory is also the packages folder that has all the DLL files. So the path seems to be right.
Why is my project still not able to load the references?
This post is starting to get old, but as I have encountered this issue myself and fixed it, I'll share a possible solution.
I had to manually uninstall and re-install the packages by right-clicking on the problematic project, Manage NuGet packages..., then uninstall/reinstall from there.
Be careful on the packages version: be sure to grab the same, in case the project isn't using the latest.
A noticeable effect for me after this procedure is that the paths in the csproj file got updated.
Hope it'll help someone :)
Open up the csproj file for your project in a plain text editor and fix the paths for the DLL's. You may see something like:
<HintPath>packages\etc\etc\etc...</HintPath>
I changed those occurrences to:
<HintPath>..\packages\etc\etc\etc...</HintPath>
I pushed this change from the computer that the project was working fine on and pulled them back down on the bad machine and it was no longer an issue.
Note: This wouldn't be an issue if your project file was in the same folder as your packages folder.
Does NuGet successfully restore the packages from the command line?
Try running this from the command line, from the same folder as your solution:
nuget restore WebApiTest.sln
Note, you may need to fully qualify the execution of nuget (e.g. C:\nuget\nuget.exe), or have it in your path.
You may need to download the NuGet executable, if you haven't already.
If that doesn't work, hopefully it will shed some light on why!
What fixed the missing project references for me was to simply:
Close Visual Studio
Delete the "packages" folder where all the nuget packages are stored (probably at your solution-level or else project-level directory)
Open the solution again in Visual Studio
If you have automatic package restore on, just rebuild, else first restore the nuget packages (from the solution context menu) and then rebuild.

Resources