Reference hell accessing .netstandard with framework VS2019 preview - visual-studio

I can get my .net standard 2.0 package working in a .net framework 4.7.2 dll if I do the following steps
In my standard project VS2019 61.4.4 right click the project and select pack to create the .nupkg
Then I set up a nuget package source for the package
In my framework project I install nuget package
I get the following dialog
I choose PackageReference in project file
I answer yes to accept licensing
Then I can see the following
And I can get my project working.
However on a different machine running VS2019 16.5.0 Preview 2.0, I do not get the dialog asking me to choose the package manager format.
Instead the references look like
and I can not get my project working.
[Update]
After following Lance's link to migrate packages.config to PackageReference
The project looks like
I was able to remove the unwanted packages by right clicking references and choosing Remove Unused References
The program worked!

Go Tools=>Nuget Package Manager =>General => Package Management You can control the behavior by Allow format selection on first package install. Enable the checkbox and restart VS, this change will take effect.
And note the dialog only appears when we install first package in current project. So if you create a new project and install package, it will appear. And since you once installed packages in that project, the dialog won't appear in WindowsFormApp2 any more.
(But you can easily migrate packages.config to PackageReference, see this).

Related

Global package installation using NuGet

Does NuGet support global package installation like NPM and Composer? If so, how do I do that? Also, how do I reference globally installed packages in my Visual Studio projects?
So learning from #Lance's tips, I went ahead and checked %userprofile%\.nuget\packages folder, and indeed it contains all the packages that I have downloaded in the past. Unfortunately though, Visual Studio (I'm using Community 2019) does not allow you to install any of these packages into a new project. The Browse page in NuGet Package Manager UI displays online results only from nuget.org.
But then I found another clue. In Visual Studio Tools > Options > NuGet Package Manager > Package Sources, you can add custom sources. So I went ahead and added my cache folder as an alternate source.
Note that there is a separate "Machine-wide package sources" entry too that cannot be modified. I checked that folder and it contains mostly Microsoft's own packages (one exception that I found there was NewtonSoft.json). I have no idea how this folder is different from the nuget cache folder and how I can download a package to this folder.
So far so good. The Package Manager now shows all previously downloaded packages from cache when I select this source from the drop down (sources dropdown is in top-right corner). I can then select a package and install it from local source instead of downloading it from the Internet.
Hope this helps someone down the line.

How to remove sqlite.net.platform.xamarinandroid from xamarin android project

I am trying to work on sqlite related operation's on my android project but in latest android version's getting fallowing exception i.e system/lib/libsqlite.so. Most of the post suggest to remove all sqlite pcl related packages and install latest sqlite.net.xamarinandroidN package. After installing they are mentioned remove old sqlite.net.platform.xamarinandroid dll but I am unable to remove that. I have go to my project references and unselect the xamarinandroid.dll and clean and rebuild then it's dll again added to the project automatically. Most of are mentioned that after removing that old dll only the newly installed sqlite is worked. Please suggest how can I remove old sqlite. I am using sqlite.net.xamarinandroidn and sqlite.net.pcl-async packages in my project.
Right click on your project.
Click on "Manage NuGet packages"
Open the "Installed" tab.
Hover over the package you want to uninstall, then click on the red X or you can click the Uninstall button that should be displayed on the Right.
I suggest deleting all the SQLite packages, then reinstall the ones you need.
And a tip:
This is the package you want to add (I found this in assembly references):
This is what the package will look like in your projects References once added:
Then these ones you can add through the NuGet Package Manager:

TFS solution is downloaded along with the Nuget Packages but the references are missing?

I'm training 5 people on using Visual Studio. They've mapped their drives and have "downloaded" the solution from TFS which contains 10 projects. All located at the same depth in TFS folder structure. When the new folks download the solution there's one project that doesn't get the NUGET references even though the Package folder (created by NUGET) is at the same depth of the other 10 projects when viewed in TFS.
We know how to add these manually but is there a way to automatically have VS do it? Why would only one project lose it's reference with the Package Folder right there?
It seems you are still using MSBuild-Integrated package restore approach. If NuGet recognizes that the MSBuild-Integrated package restore approach is enabled for the solution, Automatic Package Restore is skipped.
You need to migrating MSBuild-Integrated solutions to use Automatic Package Restore, then the packages will be restored automatically.
In addition, you need to update you NuGet manager to the latest version in VS Tools--Extensions and Updates. And make sure Visual Studio is configured to 'Allow NuGet to download missing packages' and 'Automatically check for missing packages during build in Visual Studio' in VS Tools--Options--NuGet Package Mnager--General.
To Fix:
Unload all projects first, then right click and select edit project.
Find this line:
<Import Project="$(SolutionDir)\.nuget\nuget.targets" />
Comment it out.
Reload all the projects and compile.
This applies to Nuget api version 2.
Note you may configure all projects for Nuget at the solution level.
The package manager for the solution presents a set of check boxes for every project along with the buttons (Install or Uninstall).

NuGet Package Manager not seeing one package as already updated

I want to know how I can debug a NuGet package not properly showing as updated. In my specific case the package for jQuery.Validation is (the only one left) in the "Update" list, but hitting the update button does nothing. Here's the dialog for Managing NuGet Packages for my solution:
Hitting the "Update" button will give an additional popup:
As you can see everything seems slightly grayed out (what does that mean?). Hitting "Ok" just brings me back to the other dialog.
The main problem is that I don't know how to debug this sort of problem. I've tried doing the following:
Opening the Package Manager Console to see if it logs any trouble. No dice.
Checking the jquery.validate.min.js file, which mentions version 1.13.1, which is in fact the one mentioned in the dialog as the newest version.
Checking the packages.config file, which also mentions my solution includes version 1.13.1.
Restarting Visual Studio. No dice.
Remove the package. Re-add the package. No dice (not even after restarting Visual Studio again).
Is this just a bug in the Package Manager or the package? How can I further debug the root cause of this problem?
I'm using Visual Studio 2012, have updated the product as well as all extensions (including the NuGet package manager). The solution was originally based on an MVC 2 template, and has been updated for each major MVC release (currently up to MVC 5). Only this particular package is giving trouble, I've succesfully updated 10+ other packages just before this one.
This can happen if you have an old NuGet package left in the packages directory.
When managing packages for the solution the NuGet dialog will show updates for all packages that are in the packages directory even if they are not installed into any projects. If you manage the packages for the project on its own the NuGet dialog would not show any package updates as being available.
So the workaround is to remove the unwanted NuGet package from the packages directory.

Trouble removing package from Visual Studio 2010

I accidently added a package to my VS2010 MVC 3 project via the 'Manage NuGet Packages' tool in the 'Tools' menu and I would like to remove it, however after some research I can't seem to figure out how to do it.
I have tried opening up the 'Manage NuGet Packages' tool within the solution, but there seems to be no uninstall option so I searched online and found the following article on installing and uninstalling packages. It mentions right clicking on the project and choosing the 'Add Package Library Reference' option, but this doesn't exist. I did notice that the example's project is a Website type, where mine isn't as I am using a modified version of the MVC project template.
Anyway, I searched online again and found several mentions of starting VS2010 as an Administrator and then the option for uninstalling should be available in the 'Manage NuGet Packages' tool, however this didn't change anything and no uninstall option appears.
Can anyone suggest what might be the problem and how to remove this package?
Here's a link to the docs:
Go to the section entitled Removing a Package, you can use the console to uninstall the package you want.
From the Library Package Manager, click the Installed Packages tab, then click Manage on the package you want to remove. Clear the checkbox for the solution/project you want the package uninstalled from, then click OK.
Or, open up the Package Manager Console and type "uninstall-package YourPackageName".

Resources