BetterPackageReferences 1.0.0

There is a newer version of this package available.
See the version list below for details.
NuGet\Install-Package BetterPackageReferences -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
dotnet add package BetterPackageReferences --version 1.0.0
<PackageReference Include="BetterPackageReferences" Version="1.0.0">
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add BetterPackageReferences --version 1.0.0
#r "nuget: BetterPackageReferences, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install BetterPackageReferences as a Cake Addin
#addin nuget:?package=BetterPackageReferences&version=1.0.0

// Install BetterPackageReferences as a Cake Tool
#tool nuget:?package=BetterPackageReferences&version=1.0.0


This project consists of a MSBuild targets file that provider greater control over NuGet dependencies when using SDK-style projects.

When packing SDK-style projects, there is no control over the resulting NuGet package's dependencies. The resulting package merely specifies the minimum version that is accepted. This is a problem because a later version of the dependency may contain breaking changes.

This project allows to specify stricter version requirements for each referenced NuGet package.

The following version range types are supported:

Type Description Resulting version range from 1.2.3
Exact Exact version match. Only this specific version will be allowed. [1.2.3]
SemVer Allow any minor version increment, but require the same major version. [1.2.3, 2.0.0)
Minimum Minimum version, inclusive. Any superior version will be allowed. 1.2.3


Simply install this package:

Install-Package BetterPackageReferences

By default, the following version range types are assumed:

Reference type Default value Control Variable
ProjectReference Exact DefaultVersionRangeTypeForProjectReferences
PackageReference SemVer DefaultVersionRangeTypeForPackageReferences

The defaults can be changed by setting the corresponding variable:


The version range type can also be configured for a specific reference by adding the VersionRangeType metadata:

<ProjectReference Include="..\OtherPackage\OtherPackage.csproj">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.1">


<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="BetterPackageReferences" Version="1.0.0">

    <PackageReference Include="AutoMapper" Version="7.0.1" />
    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.1">

    <ProjectReference Include="..\OtherPackage\OtherPackage.csproj" />


Packing the above project will result in a NuGet package with the following metadata:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="">
      <group targetFramework=".NETStandard2.0">
        <dependency id="AutoMapper" version="[7.0.1, 8.0.0)" />
        <dependency id="Microsoft.Extensions.Logging.Abstractions" version="[3.0.1]" />
        <dependency id="OtherPackage" version="[1.2.3]" />
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 157 11/5/2021
1.0.4 278 12/14/2020
1.0.3 384 10/16/2020
1.0.2 307 9/8/2020
1.0.0 361 12/1/2019