When your C# projects are referencing NuGet packages, you are always encouraged to update to latest version.
This can be annoying, when you really don’t want to.

In the world of Microsoft Dynamics 365/CE/CRM, you may have to use SDK of previous major version (8.x), while Visual Studio still wants you to use the latest available packages (9.x).

But there IS a way to tell Visual Studio to only suggest updates for the major version your code supports.



This is a common packages.config file in a Dynamics 365 8.2 project:


This setup gives me two recommendations for updates:

Visual Studio NuGet packages

And every time I check my packages, I will be encouraged to update these.


Telling Visual Studio what you want

By manually editing the packages.config file, you can tell VS to ignore versions based on a wildcard pattern.

Adding the attribute allowedVersions lets you specify for example which Major versions you are interested in for this project.


The syntax is not really like anything I have ever seen before, but following the documentation on docs.microsoft.com shows you what is possible.

Now the suggested updates I am presented are only the ones I actually want.


We can see in the image above that latest version of this package is v9.0.2.4, but when checking which version is actually suggested, it will be the latest with Major version 8, as instructed in the packages.xml file.

And versions with Major other than 8 are displayed as Blocked by package.config.

Looking at Installed packages, I still see the latest versions available on NuGet, but they are not listed as available Updates.



Many times you miss information of relevant updates, as you get used to ignore proposed updates to packages that you do not want in your project.

Adding the allowedVersions attribute in the packages.config file lets you trust the suggestions, which will help you keep your code up to date.

The post Telling Visual Studio not to use latest packages appeared first on The Dynamics 365 Trenches.