// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Microsoft.Extensions.Cli.Utils; using Microsoft.Extensions.CommandLineUtils; namespace Microsoft.AspNetCore.Server.IISIntegration.Tools { public class Program { public static int Main(string[] args) { var app = new CommandLineApplication { Name = "dotnet publish-iis", FullName = "Asp.Net Core IIS Publisher", Description = "IIS Publisher for the Asp.Net Core web applications", }; app.HelpOption("-h|--help"); var publishFolderOption = app.Option("--publish-folder|-p", "The path to the publish output folder", CommandOptionType.SingleValue); var projectPath = app.Argument("", "The path to the project (project folder or project.json) being published. If empty the current directory is used."); app.OnExecute(() => { var publishFolder = publishFolderOption.Value(); if (publishFolder == null) { app.ShowHelp(); return 2; } Reporter.Output.WriteLine($"Configuring the following project for use with IIS: '{publishFolder}'"); var exitCode = new PublishIISCommand(publishFolder, projectPath.Value).Run(); Reporter.Output.WriteLine("Configuring project completed successfully"); return exitCode; }); try { return app.Execute(args); } catch (Exception e) { Reporter.Error.WriteLine(e.Message.Red()); Reporter.Output.WriteLine(e.ToString().Yellow()); } return 1; } } }