I have the following problem
During development of a net core package MyPackageA
I want to use a nuget package MyPackageB 1.1.1234
but the package itself should be compatible with MyPackageB >= 1.1 and < 2.0
The old way (Framework .NET 4.7) I would do it this way
- Having a
MyPackageA.csproj
project with apackages.config
<?xml version="1.0" encoding="utf-8"?><packages><package id="MyPackageB" version="1.1.1234" targetFramework="net472" /></packages>
- Having a
MyPackageA.nuspec
file
<?xml version="1.0"?><package ><metadata><id>$id$</id><version>$version$</version><title>$title$</title><authors>$author$</authors><owners>$author$</owners><licenseUrl>https://mycompany.tld/</licenseUrl><projectUrl>https://mycompany.tld/</projectUrl><iconUrl>https://mycompany.tld/favicon.ico</iconUrl><requireLicenseAcceptance>false</requireLicenseAcceptance><description>$description$</description><releaseNotes></releaseNotes><copyright>$copyright$</copyright><tags>mytags</tags><dependencies><dependency id="MyPackageB" version="[1.1,2.0)"/></dependencies></metadata></package>
And using nuget.exe pack MyPackageA.csproj
for building my project.
But I am using .net core 3.1
and if I use
<ItemGroup><PackageReference Include="MyPackageB" Version="[1.1,2.0)" /></ItemGroup>
inside my project file, dotnet evaluates this to the lowest version that matches the version spec, in that case 1.1.1
which is to low for building / debugging and testing.
I would need something like the allowedVersion
syntax that is available to packages.config
files, see package-versioning
<package id="MyPackageB" version="1.1.1234" allowedVersions="[1.1,2.0)" />
The nupkg-File
is generated during build with
<PropertyGroup><GeneratePackageOnBuild>True</GeneratePackageOnBuild></PropertyGroup>
I also tried to add <NuspecFile>MyPackageA.nuspec</NuspecFile>
but apparently the replacement tokens $id$ / $version$ / ...
don't seem to work anymore.
Is this possible so achive this somehow?