-
Notifications
You must be signed in to change notification settings - Fork 481
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
Usage of dotnet tools
on assemblies with CommandLineParser results in unexpected output
#931
Comments
I ran into this as well - a couple potential solutions:
using Microsoft.EntityFrameworkCore;
static void Main(string[] args)
{
if (EF.IsDesignTime)
{
Log.Logger.Here().Information("Design-time detected. Skipping server startup.");
return;
}
// Parse flags as normal, build ASP.NET application
}
internal class Flags
{
#region ASP.NET Core Flags
[Option("applicationName", Default = "MyApp", HelpText = "The name of the application.")]
public string ApplicationName { get; set; }
// Other ASP.NET flags as-needed, e.g.:
[Option("environment", Default = "Production", HelpText = "The environment the application is running in.")]
public string Environment { get; set; }
#endregion
// Rest of flags...
} |
Can't you set |
@olstakh sounds like this would work! I think the only potential downside is if you always set this, you might miss some invalid flags in other cases (e.g., when a user is using the CLI vs ASP.NET). Doing something like this could avoid such cases while still not causing errors for ASP.NET flags at design time: Parser parser = new(settings => {
if (EF.IsDesignTime)
{
settings.IgnoreUnknownArguments = true;
}
// Other options
settings.HelpWriter = Console.Error;
}); |
I was trying to add CommandLineParser to a asp.net core project of mine to conditionally apply seed and test data on runs.
If I run any sort of tool on the assembly I get output from the Parser.
F.e.
dotnet ef migrations list
I'm assuming that the tools themselves are passing these options or something along the line. Everything seems to work properly, but is this something other people have dealt with in some way?
The text was updated successfully, but these errors were encountered: