-
I have a scenario where I want to conditionally apply settings when working with the fluent interfaces - i.e. in this case the DotNet tool. I can see that there is a Configure being passed in and that in turn is using a type for that relates to the specific tool's settings. Currently I'm trying to do this for executing 'dotnet test' and I need to apply some additional settings but only when specific conditions are met (i.e., checking for some property values). Alternately, I see a method signature that accepts just the settings type itself directly without the 'configure' wrapper. I was expecting that I could simply create an instance of that settings type, use normal IF statements to build it up and then pass it in but that doesn't seem to work at all. It won't even recognize that I've told it the project to use. I get the error here => MSBUILD : error MSB1003: Specify a project or solution file. The current working directory does not contain a project or solution file. It seems like we have to use the configurator method signature, or there's something missing here with how I'm building up the value to pass into the other method signature. I was looking for a better way to get a baseline/defaulted set of values to use and then extend that with my conditional logic, but I haven't found any source for that yet. Another avenue that I see but I'm not finding any information on how to use is there's a CombinatorialConfigure method signature as well. So far, I've not found any documentation on how/when to use it. My example below shows what I'm trying to accomplish here:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
There's a whole docs page describing pretty much all of that (fluent, conditional, combinatorial). I'm not sure how that can be missed? Where did you look? |
Beta Was this translation helpful? Give feedback.
-
Let me check again, I was mainly looking at reference examples. I think I found the info - just wasn't where I was expecting it. I wasn't looking under invoking CLI tools as I was thinking that was for making other external process calls, not using the 'helper' fluent interfaces for the well-supported/known tools. I had assumed that was for 'shelling out' to other tools really. So, is it correct to say that the method signature that accepts the settings type directly isn't really intended for use like I was trying? I found the .When(..) fluent method so that should meet my needs, but I'm still a bit surprised that the direct path didn't work as one would expect. Thanks! |
Beta Was this translation helpful? Give feedback.
-
The one challenge I'm still facing is that I can't plug in a true lambda like in my example where there's logic that supports adding the setting; It would be very convenient in the future if I could do that so I could have the one single When(..) clause encapsulate both the tweak to the settings -and- any supporting logic, i.e. my filename lookups. i.e. When(bool, Action<Configure< T >>) For now, I can work around that, but it would let me have a little 'cleaner' code (imo) if I could have nested the other code in there. |
Beta Was this translation helpful? Give feedback.
-
For anyone else coming across this via searching, the page is located @ https://nuke.build/docs/common/cli-tools/#conditional-modifications |
Beta Was this translation helpful? Give feedback.
There's a whole docs page describing pretty much all of that (fluent, conditional, combinatorial). I'm not sure how that can be missed? Where did you look?