[Question] Unrecognized command or argument handling
ko-vasilev opened this issue · 2 comments
Hello,
I'm trying to use this library with WixSharp.
For some reason, the WixSharp needs to pass some custom arguments to the application that I don't need myself. So I see the following error:
Unhandled Exception: McMaster.Extensions.CommandLineUtils.UnrecognizedCommandParsingException: Unrecognized command or argument '/MSBUILD:MyProjectName'
I tried adding SetRemainingArgsPropertyOnModel
convention and RemainingArgs
property on my model, but that didn't help.
What I end up doing right now is the following:
...
try
{
return commandLineApplication.Execute(args);
}
catch (CommandParsingException ex)
{
if (ex.Message.StartsWith("Unrecognized command or argument '/MSBUILD:"))
{
// This exception happens when the WIX installer is being setup for the first time
// Just ignore it.
return 0;
}
throw;
}
But it looks very ugly to me. Is there is a proper way to ignore the extra arguments I'm missing?
Thanks, looks like adding [Command(UnrecognizedArgumentHandling = UnrecognizedArgumentHandling.CollectAndContinue)]
in my case was enough.