Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget repository per branch with TFS

Tags:

merge

nuget

tfs

I have a TFS environment with the following branching setup

  • Dev - Primary working branch for developers
  • Main - Stable, releasable branch
  • Hotfix - For fixes to production code that aren't part of a normal release cycle

We're setting ourselves up to use Nuget, and I want to configure things such that code in the Dev branch pulls packages from the 'Dev' nuget repository, main from the 'Main' one, etc.

Now, I've figured things out to the point where I have a single file sitting the root of my branch that tells nuget.exe which repository to use.

I'm now trying to figure out how to have the contents of those files different in each of those branches. I can check them in to each branch separately, but that will introduce problems with merging from Dev->Main and Main->HotFix.

So, I think what I want to do is somehow exclude this particular config file from being part of merges from Dev->Main, etc. Any way to do that?

Or, alternatively, is there some other way to accomplish what I want to do with Nuget, in terms of pointing it to different nuget repositories for different branches?

like image 593
Craig Vermeer Avatar asked Oct 12 '12 17:10

Craig Vermeer


1 Answers

You'll have to do some trickery...

  • Have a different feed per branch. An easy way to set up multiple feeds is www.myget.org
  • Enable NuGet package restore in the solutions you want to enroll in this behaviour
  • In the solution's .nuget\nuget.config file, add the following:
<configuration>
  <packageSources>
    <add key="Branch X packages" value="http://www.myget.org/F/corpxyzbranchxyz" />
  </packageSources>
  <disabledPackageSources />
  <activePackageSource>
    <add key="Branch X packages" value="http://www.myget.org/F/corpxyzbranchxyz" />
  </activePackageSource>
</configuration>

This does mean that you'll have to have a different nuget.config file per branch and that you should be careful when merging/branching.

like image 149
maartenba Avatar answered Oct 15 '22 17:10

maartenba