I am trying out the Centrally Managed Packages feature in NuGet and keep getting the following error in all of my projects:
NU1604: Project dependency Ardalis.SmartEnum does not contain an inclusive lower bound. Include a lower bound in the dependency version to ensure consistent restore results.
I have the following defined in the .csproj
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Ardalis.SmartEnum" />
</ItemGroup>
</Project>
and the following Directory.Build.props
defined in the root folder beside my .sln
file
<Project>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Ardalis.SmartEnum" Version="2.1.0" />
</ItemGroup>
</Project>
An interesting thing is that I am able to get the project to build in Rider, but not with the dotnet build
command. Both when running in the root folder and in the project folder. I have tried dotnet clean
on both the solution and the project.
For clarity the file structure is:
root/
├─ Directory.Build.props
├─ MySolution.sln
├─ src/
│ ├─ ProjectFolder/
│ │ ├─ ProjectFolder.csproj
What am I missing here?
I was missing a key piece of information.
Centrally managed packages should not be defined in Directory.Build.props
.
They should be defined in Directory.Packages.props
Directory.Packages.props
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Ardalis.SmartEnum" Version="2.1.0" />
</ItemGroup>
</Project>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With