How to wrap existing tool commands? #1535
Unanswered
W-Sebastian
asked this question in
Q&A
Replies: 1 comment
-
I ended up doing this public static T SetDotNetBuildArguments<T>(this T o, Configure<DotNetBuildSettings> configure) where T : SomeBuildSettings
{
var options = configure.Invoke(new DotNetBuildSettings());
var dotNetArguments = GetArguments(options);
string[] fullCommand = [DotNetTasks.DotNetPath.DoubleQuoteIfNeeded(), ..dotNetArguments];
return o.SetProcessAdditionalArguments(fullCommand);
[UnsafeAccessor(UnsafeAccessorKind.Method, Name = nameof(GetArguments))]
static extern IEnumerable<string> GetArguments(ToolOptions settings);
} which is quite hackish but for now it works. I will consider another approach later on. |
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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Before creating an issue I want to start a discussion to see if I am missing something.
Consider a simple compile command:
Assuming this command would resolve to
dotnet build <some_settings>
I would like a way to wrap this command in another one (CLI.Wrap or using the custom tool interface) and runmy_custom_tool.exe <flags> -- "dotnet build <some_settings>"
.How can I achieve this using the API without reflection? It seems I cannot access the
ToolOptions.Arguments
.Ideally I would like to have the Task build the invocation for me and return it so I can use it further.
Just to be clear, this is a very simple example I am giving here, I have more complicated commands running that needs to be wrapped depending on various conditions. This also means that secrets should not be masked when passed here and probably a bunch of other logic which would be beneficial to reuse in a way.
Edit: To be honest, the more I thought about it, the less reasons I see for not exposing the Tool Path and the Arguments publicly.
Even if one would refactor internals or change the design philosophy there is no way to get rid of "arguments" and "command being executed" especially if exposing them as string (through a dedicated interface or whatever API makes sense).
Beta Was this translation helpful? Give feedback.
All reactions