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

How to manage Nuget package dependency version with project references from a build server

$
0
0

I have a simple project dependency structure:

project A references project B

On my build server, both projects are built as Nuget packages: package A and package B.

In project B, I have the package version set to 2.0.0 manually. when I test building project A in Visual Studio, the Nuget package A produced has a dependency on package B of version 2.0.0. This is the desired behaviour.

On the build server however, we need to auto increment the version number so the MSBuild command used to build project A has /p:Version={version} where {version} is whatever version number determined by the build server.

Using the /p:Version={version} switch in MSBuild causes Nuget package A to have a dependency on package B of the exact same {version} instead of 2.0.0. This is very problematic, as we need to control the Nuget package dependency to package B on a specific version.

So here are all the things I've tried to get around this problem but all of them have their significant drawbacks:

  1. Instead of having project A referencing project B, reference prject B's NuGet package - package B.

    You lose project reference in this case, which can be a pain when you need to debug project A and B together.

  2. Bundle the assembly of project B into package A.

    So package A doesn't have a dependency on package B. However, because project B is also referenced by project C, D and E. If I do that to all of them, all packages will have the same project B assembly.

    When all packages are referenced by another project, they overwrite each other's assembly from project B, so some of them may have an older version of the assembly overwriting a newer version, causing unpredictable runtime problems.

  3. Have the build server update the Version element in project A's project file:

    <PropertyGroup>    <Version>1.2.3</Version></PropertyGroup>

    then run MSBuild command without the /p:Version={version} switch.

    However, if the build server updates and commits the actual project file in our source control, this triggers the build server to build this project again, and it goes into an infinite loop.

This is where I'm at right now, trying to find a good solution to fulfil the following criteria if possible:

  1. The build server determines the version for both project A and B, and produces the corresponding Nuget packages with their version respectively.
  2. Package A should depend on the correct version of package B which is also built by the build server.
  3. Project A should reference project B as regular project reference.

Does anyone know if this is even possible?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



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