Let's say I am working on a Feature (C# project) that is toggled off, ie not ready to be released.
My project depends on a component via nuget, which is also something I maintain.
My feature requires changes to the component, as well as my consuming project.
I need to make intermediate releases, and I prefer not to branch.
In my project, I can toggle the Feature off and ship. Question is : how do I use nuget in a feature toggled project, such that if Feature is off, I use version X of component, and version X+1 when the feature is on.
packages.config
The only thing I can think of is, use a different feed for non-release environment, but that could lead to other logistical issues.
Edit:
My builds run on a CI server, so I need to be able to script it somehow.
If you control the NuGet source then you can use the Pre-Release functionality .
Essentially you version control your Nuget packages by suffixing them with -alpha
or -beta
and then in Visual Studio you tick the check box for "Include prelease" in you NuGet package feed.
For using a switch on a build server I suggest you look at using MSBuild / MSBuild Community Tasks / MSBuild Extension pack.
You can run a build step using MSBuild that can examine a config file and amend a .nuspec file. I don't have the source to hand as it was a while ago, but it is possible to use xml / msbuild to parse an xml file and apply changes to it. IIRC a big "gotcha" was that you need to specifiy the .nusepc
namespace
<package xmlns="http://schemas.microsoft.com/packaging/2016/06/nuspec.xsd">
when you are parsing the nuspec file.It should then be possible to target the <dependencies>
element and suffix all the dependecies with the pre-release tag.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.