Unable to update NuGet package - vb.net

Working with VS2015 I recently updated an add-on I use, ActiveReports, to a new version. Previously I had my application set for netframework 4.0, the new update for ActiveReports required at least netframework 4.5 so I changed the project to use that version.
I am getting the following error now when I build the project:
"Some NuGet packages were installed using a target framework different from the current target framework and may need to be reinstalled. Visit http://docs.nuget.org/docs/workflows/reinstalling-packages for more information. Packages affected: Microsoft.Bcl, Microsoft.Net.Http"
I have been looking at the various options suggested to address this none have worked. The last one I tried from Tools> NuGet Package Manager > Package Manager Console resulted in the following message:
PM> Update-Package
Attempting to gather dependency information for multiple packages with respect to project 'My Project', targeting '.NETFramework,Version=v4.5'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Resolution was successful but resulted in no action
There are no new updates available.
No package updates are available from the current package source for project 'My Project'

I can reproduce this by:
creating a new project as .NET 3.5, installing NuGet package Newtonsoft.Json" (just for example).
Changing my project to .NET 4.5
Then I receive an error:
Severity Code Description Project File Line Suppression State
Error Some NuGet packages were installed using a target framework different from the current target framework and may need to be reinstalled. Visit http://docs.nuget.org/docs/workflows/reinstalling-packages for more information. Packages affected: Newtonsoft.Json ConsoleApp7 0
To resolve:
Uninstall the existing NuGet packages (for that project), and reinstall them:
How:
Right-click your Solution:
Choose "Manage NuGet Packages for Solution..."
Navigate to the "Project" you changed to .NET 4.5
Choose "Uninstall", then try to reinstall them, using the same steps.
After re-installation of the package is complete, the build error is gone.

Related

Unable to Install Microsoft.Toolkit.Uwp.UI.Controls 3.0.0

Using NuGet Package Manager, I get this error message:
Could not install package 'Microsoft.Toolkit.Uwp.UI.Controls 3.0.0'.
You are trying to install this package into a project that targets 'native,Version=v0.0',
but the package does not contain any assembly references or content files that are compatible with that framework.
For more information, contact the package author. 0
The app is a Blank App (C++/winRT). Visual Studio 15.8.0 Preview 4.0.(10.0.17134.0, 10.0.17704.0)
Despite it's name, the Windows Community Toolkit is only intended for C# developers.

NuGet Package Reference Versioning and VS Package Manager

I have been setting the package references in my .csproj files to accept any minor version of dependent NuGet packages (see NuGet Package Versioning reference examples). An example of this might be as per the below:
<!-- Accepts any 6.2.x version. -->
<PackageReference Include="ExamplePackage" Version="6.2.*" />
However, whilst this appears to work (i.e. the latest release version of 6.2.2 is restored), the NuGet package manager GUI built into Visual Studio appears to read the package reference as 6.2.0 and prompts me to upgrade to 6.2.2.
Performing a restore from the command line appears to download 6.2.2 but I cannot get the VS Package Manager to play ball.
Is there any way to get the VS Nuget Package Manager GUI to accept that 6.2.2 is what has actually been restored?
However, whilst this appears to work (i.e. the latest release version of 6.2.2 is restored), the NuGet package manager GUI built into Visual Studio appears to read the package reference as 6.2.0 and prompts me to upgrade to 6.2.2
This is a known issue about the PackageReference versioning with wildcard.
It seems use a wildcard * is the correct way for NuGet Restore to float to a higher version. However, the NuGet package manager GUI still takes the lowest version. The current workaround is update the nuget package to the latest version via NuGet package manager GUI, but this way will remove the wildcard *.
For tracking this NuGet issue, I recommend that you vote on and follow the earlier reported issue for updates and fix notifications:
https://github.com/NuGet/Home/issues/3788
Hope this helps.

Visual Studio Online build error about NuGet client version (v3.0 or above required)

I am trying to setup a CI build using Visual Studio Online but I am getting the following error about the NuGet client:
The 'System.Net.Http 4.0.0' package requires NuGet client version '3.0' or above, but the current NuGet version is '2.8.60318.667'.
Solution builds and deploys fine directly from my Visual Studio 2015 itself but I am unable to get it to build in VSO. Does anyone if NuGet 3.x is installed on hosted build controllers or if I can supply my own copy along with my solution?
It's hard to guess by the question what build tasks are used. If you use VSBuild/MSBuild, it is only possible to turn "Restore NuGet packages" on, but there's no influence on the NuGet version.
However, if you turn this checkbox off, and instead add another build task called NuGet Installer before the main build step, you'll be able to provide a custom path to NuGet.exe. In the case of hosted build agent, the most obvious option is to commit required version of NuGet.exe to the repo, and then reference it from the build step:
Sounds like a hack, but it might work in your case.

VisualStudio.com (Visual Studio Team Services) builds failing on nuget package dependencies

Thought I would try and get the most out of my visualstudio.com trial membership. I created a solution with a few projects, pushed it to the Microsoft git source control provider, configured a build definition and tried to build it on the project server. However it keeps failing telling me:
The type or namespace name 'Moq' could not be found (are you
missing a using directive or an assembly reference?)
I know this means that the build server can't find the Moq.dll library. I had installed it using NuGet, but configured my .gitignore to keep the packages folder out of source control. I also enabled NuGet package restore for the solution and pushed nuget.exe, nuget.targets, and nuget.config (all 3 of the files in the .nuget folder) along with all of the other project files.
Now I am sure I could get the build to work if I pushed the packages folder too, but I want to keep the nuget packages folder out of source control. So I am wondering, is this possible? The visualstudio.com docs say that the build servers have visual studio 2013 installed, and because of this I assume that nuget package restore would work to download the missing dll's so that they can be resolved by MSBuild. Is this right? Or to use automated CI builds at visualstudio.com, do you need to have your packages under source control?
According to the log file, nuget package restore downloaded the package. What gives?
Project "C:\a\src\MySln.sln" (1) is building
"C:\a\src\Tests\MySln.ProjA.UnitTests\MySln.ProjA.UnitTests.csproj"
(3) on node 1 (default targets). RestorePackages:
"C:\a\src.nuget\NuGet.exe" install
"C:\a\src\Tests\MySln.ProjA.UnitTests\packages.config" -source ""
-NonInteractive -RequireConsent -solutionDir "C:\a\src\ " Restoring NuGet packages... To prevent NuGet from downloading packages during
build, open the Visual Studio Options dialog, click on the Package
Manager node and uncheck 'Allow NuGet to download missing packages'.
All packages listed in packages.config are already installed.
PrepareForBuild: Creating directory "obj\Debug\".
ResolveAssemblyReferences: Primary reference "Moq". C:\Program Files
(x86)\MSBuild\12.0\bin\amd64\Microsoft.Common.CurrentVersion.targets(1635,5):
warning MSB3245: Could not resolve this reference. Could not locate
the assembly "Moq". Check to make sure the assembly exists on disk. If
this reference is required by your code, you may get compilation
errors.
[C:\a\src\Tests\MySln.ProjA.UnitTests\MySln.ProjA.UnitTests.csproj]
This line is also in the build log file, below the above:
Considered "..\packages\Moq.4.1.1311.0615\lib\net40\Moq.dll", but it didn't exist.
I had this same error but it was occurring on our build server. I had added Moq via NuGet, checked in the project and everything was fine. I then moved the project into a new folder in TFS and the build server just couldn't seem to find Moq. It was building great locally. I ended up fixing the problem by making sure all of my changes were checked into source control and then deleting my local source code directory. I got latest and my test project realized it needed a new copy of Moq. I blame TFS/ source safe or what ever the Visual Studio integration module is for not adding it to source control at some point in time.
Figured this one out on my own. Turns out I had added the nuget packages before moving the test project into a Tests subfolder. The solution still built on my LM, probably because the dependencies were already copied to bin/Debug. After reinstalling the nuget packages, the solution built on vs.com.

NuGet Issue installing SignalR and Raven

I am trying to use NuGet to add SignalR and Raven to a new ASP.Net MVC 4 project.
If I do SignalR first, then try to add Raven I get the following error:
Install failed. Rolling back... Install-Package : Already referencing
a newer version of 'Newtonsoft.Json'.
If I install Raven first, then SignalR I get:
Install failed. Rolling back... Install-Package : Updating
'Newtonsoft.Json 4.5.7' to 'Newtonsoft.Json 4.5.8' failed. Unable to
find a version of 'RavenDB.Client' that is compatible with
'Newtonsoft.Json 4.5.8'.
I thought NuGet was meant to handle this sort of thing?
How can I get them both added?
It appears that RavenDB.Client has an exact-version constraint on Newtonsoft.Json = 4.5.7, while SignalR has a more relaxed constraint of '4.5.4 or higher' (actually a constraint imposed by one of its own dependencies, SignalR.Server).
I managed to get your above scenario working with some manual tweaking:
Created new MVC4 project
Opened up packages.config and added an 'allowedVersions="[4.5.7]"' attribute to the Newtonsoft.Json package entry
Opened the package manager console (View... Other windows... Package Manager Console) and ran update-packages to pull in latest code for all default dependencies (takes a while)
Again in package manager console, ran install-package RavenDB.Client
Finally in package manager console, ran install-package SignalR
I tried a few combinations of ordering the above but it wasn't liking it - the thing that let it work seems to be the manual editing of packages.config to lock the version of Newtonsoft.Json to 4.5.7 so that subsequent installs don't trash the referenced version.
We ran into this exact issue, but ultimately pulled in the Raven assemblies manually (so we could target a specific version).
Something that we came across is that it is possible to force Nuget to install a package using the command line tools:
How to install an older version of package via NuGet?
I ran into the same issue, but instead decided to install an older version of SignalR. Version 4.0 (February 2012) has a dependency on NewtonSoft >= 4.0.7, and this installs correctly with RavenDB already installed:
Install-Package SignalR -Version 0.4.0
I got the same problem with Raven and the standard MVC template. I wanted the latest version of Newtonsoft.Json so I solved it differently.
I checked what dependencies RavenDB Client had and then installed the latest version of them first Newtonsoft.Json and NLog
I then installed the packet in the Packet manager Console with the -IgnoreDependencies flag.
Install-Package -Id RavenDB.Client -IgnoreDependencies
That worked fine. (I am taking a calculated risk that RavenDB is not compatible with the latest Newtonsoft.Json at the moment. But I am a Daredevil)