Skip to content
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

Choose/When/Otherwise in Targets #2056

Open
dasMulli opened this issue May 4, 2017 · 7 comments
Open

Choose/When/Otherwise in Targets #2056

dasMulli opened this issue May 4, 2017 · 7 comments
Labels
Area: Language Issues impacting the MSBuild programming language. For consideration Used for items on the backlog to raise them to the top of that list for discussion triaged

Comments

@dasMulli
Copy link
Contributor

dasMulli commented May 4, 2017

<Choose>/<When>/<Otherwise> is a nice feature that allows replacing complex conditions with what is effectively a switch-case-default but can only be used on the project level and not within targets.

Can this be changed to work within targets?
This would theoretically conflict with tasks being named Choose, are there any ways to deal with this? - like (and I feel bad suggesting this) optional xml namespace for <MSBuild:Choose> and prefer a task named Choose if defined.

@dasMulli
Copy link
Contributor Author

dasMulli commented Aug 9, 2018

@rainersigwald @jeffkl @cdmihai is this feasible at all?
I so, I'd hope to see this in 16.0. If not, go ahead and close it as "won't implement".

@rainersigwald
Copy link
Member

I don't have a strong objection to this, other than the conflict-with-task one. But it's not very high on my priority list, personally. Anybody else feel more strongly about it?

@rainersigwald rainersigwald added the Area: Language Issues impacting the MSBuild programming language. label Aug 14, 2018
@cdmihai
Copy link
Contributor

cdmihai commented Aug 14, 2018

Implementation wise it will be interesting, since the current design accepts only tasks within targets (properties and items in targets are actually implemented as tasks). But shouldn't be too hard, probably involves implementing a Choose IntrinsicTask .

@cdmihai cdmihai added the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Aug 14, 2018
@dasMulli
Copy link
Contributor Author

dasMulli commented Sep 9, 2018

Implementing a choose intrinsic task seems to be promising, I got a prototype at
https://github.com/dasMulli/msbuild/tree/feature/choose-in-targets (Compare)

If there is interest in taking this as a community contribution I could invest more work into it.

@cdmihai
Copy link
Contributor

cdmihai commented Sep 12, 2018

Took a quick look over it and looks good! Feel free to open it up as a WIP PR to get more feedback.

My take on it:

  • not sure whether to allow task executions, or to restrict it to only what's allowed in the choose elements outside of targets.
  • add more tests. To find the relevant tests to duplicate (or transform them into [Theory]) you can search for <choose in all the *_Tests.cs files. But do send the WIP PR before you do this.

@rainersigwald
Copy link
Member

Team triage: #3851 is a solid-looking implementation of this, but we currently think we should wait for a major release to add this type of language feature. If we want to take this for 17.0, it should definitely start with reviving #3851.

@rainersigwald rainersigwald removed the help wanted Issues that the core team doesn't plan to work on, but would accept a PR for. Comment to claim. label Jul 9, 2019
@rainersigwald rainersigwald added the For consideration Used for items on the backlog to raise them to the top of that list for discussion label Dec 8, 2020
@AR-May AR-May added the triaged label Feb 21, 2024
@voroninp
Copy link

Hello there ;-), what's the curent status of this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Language Issues impacting the MSBuild programming language. For consideration Used for items on the backlog to raise them to the top of that list for discussion triaged
Projects
None yet
Development

No branches or pull requests

5 participants