So one might have heard about FluentAssertions, to change its licence to commercial https://fluentassertions.com/releases/.
Here is the question: I am using Central Package Management in my SDK style project(s), want do PIN the FluentAssertions version to 7.1.0.
Is there a way to achieve this, if yes how? Just found info about transitive, but not root level packages.
For the sake of completeness, here is some code (snippets):
Directory.Build.props:
<Project>
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<IsTestProject Condition="$(MSBuildProjectName.EndsWith(.Tests))">true</IsTestProject>
</PropertyGroup>
</Project>
Directory.Packages.props
<Project>
<ItemGroup Condition="$(IsTestProject) == 'true'">
<PackageVersion Include="FluentAssertions" Version="7.1.0" />
</ItemGroup>
</Project>
Any test projects .csproj
<Project Sdk="Microsoft.NET.Sdk">
<PackageReference Include="FluentAssertions" />
</Project>
Thanks for all answers <3
Edit: NuGet package manager should not notify about the "unwanted new" package version.
You can use nuget package versioning rules to pin your package version to version 7.
The best way to to this is to use a version range that includes the current version 7.1.0 (with the open square bracket [
) but excludes version 8 and above (with the close braces )
).
This way if there are updates released for version 7 e.g. version 7.2.0 they will show as available upgrades.
<PackageVersion Include="FluentAssertions" Version="[7.1.0,8)" />
Note that you will have to upgrade by manually editing the version number as nuget package manager tends to overwrite the range with a specific version if you use the UI.