Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            bool quiet = false;

            if (File.Exists(_logFile))
            {
                File.Delete(_logFile);
            }

            Log.Logger = new LoggerConfiguration()
                         .MinimumLevel.Debug()
                         .WriteTo.File(_logFile)
                         .CreateLogger();

            var parser       = new Parser(with => with.HelpWriter = null);
            var parserResult = parser.ParseArguments <Options>(args);

            parserResult
            .WithParsed <Options>(o =>
            {
                quiet = o.Quiet;
                if (string.IsNullOrEmpty(o.VmSize) && string.IsNullOrEmpty(o.CustomConfig))
                {
                    Log.Error("Please set value for Vitrual machine size or path to custom config file");
                }
                else
                {
                    AssemblyAzurePackage a = new AssemblyAzurePackage(o.PathToCsPack, o.SourceDir, o.OutDir, o.Framework.ToString(), o.VmSize, o.CustomConfig);
                    a.Build();
                }
            })
            .WithNotParsed(x =>
            {
                var helpText = HelpText.AutoBuild(parserResult, h =>
                {
                    h.AutoHelp    = false;         //hide --help
                    h.AutoVersion = false;         //hide --version
                    return(HelpText.DefaultParsingErrorsHandler(parserResult, h));
                }, e => e);
                Console.WriteLine(helpText);
            });

            if (!quiet)
            {
                Console.WriteLine("For exit please press any key...");
                Console.ReadLine();
            }
        }
        private void BtnCompile_Click(object sender, RoutedEventArgs e)
        {
            string config = TbConfig.Text;

            if ((bool)RbUseStandard.IsChecked)
            {
                config = "";
                if (string.IsNullOrEmpty(SelectedSize))
                {
                    if (string.IsNullOrEmpty(CbVmSize.Text))
                    {
                        MessageBox.Show("Please fill VM Size", "Azure Compiler", MessageBoxButton.OK, MessageBoxImage.Warning);
                    }
                    else
                    {
                        SelectedSize = CbVmSize.Text;
                    }
                }
            }

            Settings.Default.AcuVersion       = SelectedAcumatica.AcumaticaRelease;
            Settings.Default.SDK              = TbSDK.Text;
            Settings.Default.PathToSource     = TbSource.Text;
            Settings.Default.PathToOutput     = TbOutput.Text;
            Settings.Default.CustomConfigRB   = (bool)RbUseCustom.IsChecked;
            Settings.Default.CustomConfigPath = TbConfig.Text;
            Settings.Default.VMSize           = SelectedSize;
            Settings.Default.Save();

            AssemblyAzurePackage assemblyAzure = new AssemblyAzurePackage(TbSDK.Text, TbSource.Text, TbOutput.Text, SelectedAcumatica.FrameworkId, SelectedSize, config);
            int result = assemblyAzure.Build();

            if (result == 0)
            {
                MessageBox.Show("Compilation completed", "Azure Compiler", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else if (result == 1)
            {
                MessageBox.Show("Compilation finished with error. For more information read file log.txt", "Azure Compiler", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }