Exemple #1
0
        private async void btnPublishWebsite_Click(object sender, EventArgs e)
        {
            btnPublishWebsite.Enabled = false;
            try
            {
                var parameters = new PublishWebsiteParameters();
                parameters.WebRoot         = tbWebRoot.Text;
                parameters.OutputName      = tbOutputName.Text;
                parameters.OutputDirectory = tbOutputDirectory.Text;
                parameters.IgnorePattern   = tbIgnorePattern.Text;
                parameters.Configuration   = cbConfiguration.Text;
                parameters.Framework       = cbFramework.Text;
                var publisher = new WebsitePublisher(parameters);
                await Task.Run(() => publisher.PublishWebsite());

                MessageBox.Show(Resources.PublishSuccessfully);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                btnPublishWebsite.Enabled = true;
            }
        }
Exemple #2
0
        private async void btnPublishWebsite_Click(object sender, EventArgs e)
        {
            btnPublishWebsite.Enabled = false;
            try {
                var parameters = new PublishWebsiteParameters();
                parameters.WebRoot         = tbWebRoot.Text;
                parameters.OutputName      = tbOutputName.Text;
                parameters.OutputDirectory = tbOutputDirectory.Text;
                var publisher = new WebsitePublisher(parameters);
                await Task.Run(() => publisher.PublishWebsite());

                MessageBox.Show("Success");
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            } finally {
                btnPublishWebsite.Enabled = true;
            }
        }
Exemple #3
0
        public static void Main(string[] args)
        {
            var parameters = new PublishWebsiteParameters();
            var showHelp   = false;
            var optionSet  = new OptionSet()
            {
                { "r|root=", Resources.TheSourceWebsiteRootDirectory, r => parameters.WebRoot = r },
                { "n|name=", Resources.TheOutputName, n => parameters.OutputName = n },
                { "o|output=", Resources.TheOutputDirectory, d => parameters.OutputDirectory = d },
                { "x|ignore=", Resources.IgnorePatternInRegex, x => parameters.IgnorePattern = x },
                { "c|configuration=", Resources.WhichConfigurationToPublish, x => parameters.Configuration = x },
                { "f|framework=", Resources.WhichFrameworkToPublish, x => parameters.Framework = x },
                { "h|help", Resources.ShowThisMessageAndExit, h => showHelp = (h != null) }
            };

            try
            {
                optionSet.Parse(args);
                if (showHelp)
                {
                    var optionDescriptions = new StringWriter();
                    optionSet.WriteOptionDescriptions(optionDescriptions);
                    Console.WriteLine("WebsitePublisher 2.0:");
                    Console.WriteLine(optionDescriptions.ToString());
                    return;
                }
                var publisher = new WebsitePublisher(parameters);
                publisher.PublishWebsite();
                Console.WriteLine("success");
            }
            catch (Exception e)
            {
                if (e is OptionException || e is ArgumentException)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(Resources.TryWebsitePublisherHelpForMoreInformation);
                }
                else
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
Exemple #4
0
        public static void Main(string[] args)
        {
            var parameters = new PublishWebsiteParameters();
            var showHelp   = false;
            var optionSet  = new OptionSet()
            {
                { "r|root=", "The source website root directory", r => parameters.WebRoot = r },
                { "n|name=", "The output name", n => parameters.OutputName = n },
                { "o|output=", "The output directory", d => parameters.OutputDirectory = d },
                { "x|ignore=", "Ignore pattern in regex", x => parameters.IgnorePattern = x },
                { "c|configuration=", "Which configuration to publish", x => parameters.Configuration = x },
                { "f|framework=", "Which framework to publish", x => parameters.Framework = x },
                { "h|help", "Show this message and exit", h => showHelp = (h != null) }
            };

            try {
                optionSet.Parse(args);
                if (showHelp)
                {
                    var optionDescriptions = new StringWriter();
                    optionSet.WriteOptionDescriptions(optionDescriptions);
                    Console.WriteLine("WebsitePublisher:");
                    Console.WriteLine(optionDescriptions.ToString());
                    return;
                }
                var publisher = new WebsitePublisher(parameters);
                publisher.PublishWebsite();
                Console.WriteLine("success");
            } catch (Exception e) {
                if (e is OptionException || e is ArgumentException)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine("Try `WebsitePublisher --help` for more information");
                }
                else
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }