4
votes

In our dev environment, we have a Git repo which houses a common component. This repo has multiple feature branches which are publishing Nuget packages through a CI build to a common feed. In the feed, packages coming from these feature branches are identified with a prerelease tag of the branch name. As a consumer, I am looking into this feed through sources mentioned in Nuget.config file. And, I am trying to consume packages coming from a particular feature branch of that common component. But the Nuget update command which I am calling from consumer project can potentially pull a pre-release version from other branch if that package has a higher version. Pls share your inputs on how to resolve this. I am not seeing any additional arguments in update command to mention the specific pre-release tag

Thanks

Sandeep

1

1 Answers

3
votes

There are a few options:

  1. Use different feeds - clearly most complicated from the infrastructure point of view unless you can easily create feeds through a service. But this makes "update everything" commands easy.
  2. Give those packages a different identity (name), so can publish My.Product.With.FeatureA and My.Product.With.FeatureB.
  3. Use allowedVersions in packages.config to restrict updates to a version range. For this you might also need to use different minor/patch versions and not only prerelease tags for packages.

When using the new PackageReference format in VS 2017 15.1+ (already released), you have some more options

  1. Use floating references for parts of the perelease tag. e.g. 1.2.3-coolfeatureA-*.
  2. Since PackageReference is used from MSBuild, you can also define a central feature and build version (e.g. in a Directory.Build.props file) and use these in package references. E.g. you could use definitions like this in your csproj file:

    <ItemGroup>
      <PackageReference Include="My.Shared.LibA" Version="1.2.3-$(LibsFeatureBranch)-$(LibsBuildNumber)" />
      <PackageReference Include="My.Shared.LibB" Version="1.2.3-$(LibsFeatureBranch)-$(LibsBuildNumber)" />
    </ItemGroup>
    

    Together with a Directory.Build.props file (at project or solution level) containing:

    <Project>
      <PropertyGroup>
        <LibsFeatureBranch>CoolFeatureA</LibsFeatureBranch>
        <LibsBuildNumber>20170510-</LibsBuildNumber>
      </PropertyGroup>
    </Project>