Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Use a specific version of a nuget package while coding but versionspec in nuget package

$
0
0

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 a packages.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?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>