-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More flexible ways to conditionally set nuget settings (like sources) #3972
Comments
My team is in a similar situation but my plan is to have the build agent look at the same feeds as a local dev. Why do you need / want the dev experience to be different from the build agent there? Seems like a place to encourage differences from local and build agent state making harder to track down issues? |
We want the local dev experience to work for those inside and outside of microsoft and to be relatively stable. So our NuGet.config files point to public feeds that only have good builds of packages. Our CI agents, on the other hand, consume feeds that are internal-only or have untested, pre-release packages. |
My point is that a dev on your project is also probably interested in the pre-release packages (and probably producing them locally and well as triggering CI builds that produce them). The consumers of your package probably only care about the stable ones but that seem different than what a contributor (internal or external) may want? |
Good point. Yes, this happens, and when it does the dev has to modify their NuGet.config to pull the right feeds, make sure not to accidentally commit the NuGet.config change to source (this has never happened, of course |
We are still devising a system for our team to help prevent these situations but it goes as follows. We are envisioning 3 "tiers" of package sources that will always be set up in a nuget.config.
This means that a local dev gets the latest (due to time string version ordering) locally built package by default. The CI build picks up what was built from a previous step automatically (due to local path or CI path if the previous step also publishes). "True Consumers" only pick up stable nuget.org The local/CI consumers just need to make sure to use 1.0.1-* in their project.json and then it should be "easy" to ensure everyone is getting what they want based on where they are and what has been built. Since your team is already up and running, do you see any potential pitfalls with this approach? Would it work for you guys? |
We have the concept of 'tiers' too. See https://github.com/aspnet/Home/wiki/NuGet-feeds. Most common pitfall, the dash star. "1.0.1-*" is seems nice at first because you don't have to change your project for every nightly build, but give it time and dash star will hurt at some point. On numerous occasions, restore has pulled in a package version that was unexpected...and it can be hard to figure out where it came from.
Here's another pitfall, and basically the reason for requesting the concepts of environments. Chained build configurations on CI need an additional feeds to get unpublished packages from earlier build steps. |
@natemcmaster would it work for you to define the feeds and global packages folder in MSBuild by setting this in your project, or including a target that sets this and has conditions? From your example it looks like you are asking for nuget.config to support MSBuild conditionals. |
That was just one idea. I actually like the NuGet.${env}.config idea much better. I haven't tried it yet, but I see that NuGet 4 supports a RestoreSources property in MSBuild. How will this interact with NuGet.config? That said, we frequently use and will continue to need NuGet clients that are not part of MSBuild but would still benefit from NuGet.${env}.config. FWIW before asking, I gave consideration to just using the |
Can you give some examples of this? It sounds like there may be other problems here. restore should be the only component reading the package sources, and the output packages folder used for downloaded packages is written to the project.lock.json/project.assets.json file. Build should be reading the packages folder from the assets file. Is something else reading the sources? |
Here is one scenario: I work on tools such as "dotnet watch" and others. True end-to-end validation requires build+packing the dotnet-watch project, and then dotnet-restore its output into a new test project. This new test project needs to include the same package feeds used to build dotnet-watch. To ensure tests get the right packages, the build of dotnet-watch and tests (which shell execute a |
You can set $(RestoreSources) to replace the nuget.config provided sources via msbuild project or props files. Given that, you can use msbuild conditions to do what was originally desired in this issue. |
…restore (#622) ## Description Pull Request #601 implementation fails to restore. I believe I narrowed the problem down to the added `disabledPackageSources` property in nuget.config, though my access to the Nuget feed isn't currently working. This solution takes the disabling effect out of nuget.config and puts it in the Directory.Packages.props. In the .props file it conditionally restores the private Nuget feed based on the single bool prop, `AccessToNugetFeed`, defined in Directory.Build.props. Credit: [GitHub issue 1](NuGet/Home#6045), [GitHub issue 2](NuGet/Home#3972) --------- Co-authored-by: Benjamin Michaelis <[email protected]>
…restore (IntelliTect#622) ## Description Pull Request IntelliTect#601 implementation fails to restore. I believe I narrowed the problem down to the added `disabledPackageSources` property in nuget.config, though my access to the Nuget feed isn't currently working. This solution takes the disabling effect out of nuget.config and puts it in the Directory.Packages.props. In the .props file it conditionally restores the private Nuget feed based on the single bool prop, `AccessToNugetFeed`, defined in Directory.Build.props. Credit: [GitHub issue 1](NuGet/Home#6045), [GitHub issue 2](NuGet/Home#3972) --------- Co-authored-by: Benjamin Michaelis <[email protected]>
Feature suggestion:
Make it easier to vary NuGet feeds by build/test environments.
Scenario:
Build agents use different feeds than local dev builds. To enable this, our build systems rewrite NuGet.config files to ensure the build gets the right package feeds.
Using environment variables in the package feed value (#1852) isn't quite powerful enough to our build scenarios.
Ideas:
Also, if I've missed a feature that already enables these scenarios, please advise.
The text was updated successfully, but these errors were encountered: