I have a solution like that:
- Package1
- Package2
Both are Nuget packages, Package2 is referencing Package1 as a project reference. Now if I publish Package2 from what I understand this reference will get converted to Package1 Nuget (which I want), but what happens as well is that I do not have control over versioning it seems. So if I update Package1 to a new major version, that will lead to Package2 breaking.
Is there a way to control a version in this case?
This is what I have tried so far, but it is giving me some troubles during the build because of package.lock.json mismatch. (dotnet restore --locked-mode
results in NU1004: The package references haver changed")
<ItemGroup>
<PackageReference Include="Package1" Version="1.*" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Package1\Package1.csproj" />
</ItemGroup>
It seems that the generated nuspec includes this:
<dependency id="Package1" version="<Package2Version>" exclude="Build,Analyzers" />
Which means if I always publish both packages together and they will be on the same version it will work, but it of course have some obvious downsides like publishing the packages with no changes e.g.
And what I want is to control <Package2Version>
, ideally so that it would be set to version from Package1.csproj
file instead of version from Package2.csproj
file.