How to pin a package and prevent from accidentally updating? #13187
Replies: 4 comments
-
Im also wondering about this myself |
Beta Was this translation helpful? Give feedback.
-
I'd like this too. In the meantime, I hacked together this approach: Add something along the lines of the following to your Directory.Packages.props <Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="SomeLibrary" Version="1.2.3" />
...
</ItemGroup
...
<Target Name="CheckPackageVersion" BeforeTargets="Build">
<Error Condition="'%(PackageVersion.Identity)' == 'SomeLibrary' AND '%(PackageVersion.Version)' != '1.1.1'" Text="Invalid package version for SomeLibrary. Expected: 1.1.1." />
</Target>
</Project> It should fail to build because e.g., SomeLibrary 1.2.3 != 1.1.1. |
Beta Was this translation helpful? Give feedback.
-
I'd love to know the answer to this as well. If I pin a version range (e.g. @MatthewChudleigh's solution works very well in the interim (thanks for sharing!), but I'm curious to know what the official guidance is. |
Beta Was this translation helpful? Give feedback.
-
There is no way to do this today as of VS 17.13, .NET SDK 9.0.200 and NuGet 6.13. #6566 is the closest issue for that. |
Beta Was this translation helpful? Give feedback.
-
Hi! I am trying to pin a package in my CPM "Directory.Packages.props" file.
I did for example
<PackageVersion Include="Azure.Core" Version="[1.36.0]" />
BUT,
dotnet add package 1.37.0 - will change it to 1.37.0, and i will get only warning NU1608.
Also, the Rider Nuget manager seems to ignore this and shows me an update, and when updating - changes the version.
Am I doing something wrong?
How actually in Nuget world, having CPM, i can pin some package and prevent it from accidentally updating?
Beta Was this translation helpful? Give feedback.
All reactions