private async Task <int> OnExecuteAsync(CommandLineApplication app, CancellationToken cancellationToken = default) { PackingParameters packingParameters = null; string ursaConfPath = null; if (!File.Exists(ConfigurationPath) && !Directory.Exists(ConfigurationPath)) { throw new FileNotFoundException(DefaultUrsaConfFileName); } var fileAttributes = File.GetAttributes(ConfigurationPath); if (fileAttributes.HasFlag(FileAttributes.Directory)) { ursaConfPath = Directory.EnumerateFiles(ConfigurationPath) .FirstOrDefault(path => path.EndsWith(DefaultUrsaConfFileName)); } else { ursaConfPath = ConfigurationPath; } if (ursaConfPath == null) { throw new FileNotFoundException(DefaultUrsaConfFileName); } using (var streamReader = File.OpenText(ConfigurationPath)) { packingParameters = new DeserializerBuilder() .WithNamingConvention(UnderscoredNamingConvention.Instance) .Build() .Deserialize <PackingParameters>(streamReader); packingParameters.Initialize(NugetApiKey); } return(await new UrsaApplication(app) .RunAsync(packingParameters, cancellationToken)); }