Proposed 'BuildUri' Common Task #7440
Replies: 1 comment
-
Per Contributing Tasks, Replaced by #8613 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I recently worked on an issue related to the FormatUrl common task. The
FormatUrl
task is not a generalized task for formatting URLs. It is a specialized task that was probably written for a specific set of use cases. The task will, for example, replace 'localhost' with the current machine name. That could easily be counter-productive for scenarios like creating a test configuration that is meant to be distributed to multiple hosts and run locally.As an exercise, I created a task that is general and that can create and/or modify URIs. I named the task BuildUri because it is a thin wrapper around the
UriBuilder
class. BuildUri has an optional input parameter for an ItemGroup of URIs (InputUri
), optional input parameters that map to the properties ofUriBuilder
, and an output parameter for an ItemGroup of URIs (OutputUri
).For an empty set of
InputUri
, the other input parameters are used to create a new URI.For a set of 1 or more
InputUri
, the other input parameters are applied to each member of the set. e.g. a set of http URIs can be changed to used https.For the
OutputUri
, each item is set with custom metadata that reflects the properties of theUriBuilder
class. e.g. a 'UriScheme' metadata value is created on the result items. A set of URIs could be passed through the BuildUri task to add the 'UriScheme' metadata and the results could then be task or target batched by Scheme.Creating a URI might look like the following:
Creating URIs for a set of hosts might look like the following:
The code for the task itself can be seen at https://github.com/jrdodds/msbuild/blob/BuildUriTask/src/Tasks/BuildUri.cs.
I don't know how useful or valuable this task (or the functionality of this task) may be to the MSBuild community but if there is interest I can take this further and create an issue and a pull request.
Thanks
Beta Was this translation helpful? Give feedback.
All reactions