예제 #1
0
        private void buildButton_Click(object sender, EventArgs e)
        {
            targetFileDialog.FileName = fileName.Replace(".ps1", ".exe");
            if (targetFileDialog.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            ApplicationData newApplicationData;

            if (exe64svc.Checked || exe32svc.Checked)
            {
                ServiceData newApp = new ServiceData();
                newApp.ServiceName = serviceName.Text;
                newApp.Description = serviceDescription.Text;
                newApp.DisplayName = serviceDisplayName.Text;
                newApplicationData = newApp;
            }
            else
            {
                newApplicationData = new ApplicationData();
            }

            newApplicationData.ApplicationName = Path.GetFileName(fileName);

            switch (frameworkVersion.Text)
            {
            case "Framework 2.0":
                newApplicationData.Framework = Framework.Framework20;;
                break;

            case "Framework 3.5":
                newApplicationData.Framework = Framework.Framework35;
                break;

            case "Framework 4.0":
                newApplicationData.Framework = Framework.Framework40;
                break;

            default:
                newApplicationData.Framework = Framework.Framework40;
                break;
            }

            newApplicationData.DebugBuild = !buildRelease.Checked;

            newApplicationData.HideConsole = hideConsole.Checked;

            if (iconImage.Tag != null)
            {
                newApplicationData.Icon = Properties.Resources.exe;
            }

            newApplicationData.LCID = ((ComboListItem <int>)regionalSettings.SelectedItem).Value;

            newApplicationData.Mode = threadingSTA.Checked ? ThreadMode.STA : ThreadMode.MTA;

            newApplicationData.Platform = (exe32.Checked || exe32svc.Checked) ? Platform.x86 : Platform.x64;

            newApplicationData.PublisherName = authorName.Text;

            newApplicationData.PublisherOrganization = authorCompany.Text;

            newApplicationData.Version = new Version(versionBox.Text.Replace(",", "."));

            newApplicationData.AdditionalFiles.AddRange(addFiles.Items.Cast <string>());

            if (signFile.Checked)
            {
                X509Store store = new X509Store(StoreName.My);
                store.Open(OpenFlags.ReadOnly);
                foreach (X509Certificate2 mCert in store.Certificates)
                {
                    if (mCert.Thumbprint == ((ComboListItem <string>)certificateSelector.SelectedItem).Value)
                    {
                        newApplicationData.SigningInformation = new SingingInformation()
                        {
                            Certificate     = mCert,
                            TimestampServer = timestampURL.Text
                        };
                    }
                }
            }


            using (BuildLog buildLog = new BuildLog(fileName, targetFileDialog.FileName, newApplicationData, verboseBuild.Checked))
            {
                buildLog.ShowDialog();
            }
        }