private void DoAntDeployProcess(string projectPath, ProjectParam param)
        {
            var md5             = MD5(projectPath);
            var path            = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var projectPram     = JsonConvert.SerializeObject(param);
            var projectPramPath = Path.Combine(path, md5 + "_param.json");

            File.WriteAllText(projectPramPath, projectPram, Encoding.UTF8);

            var assembly          = Assembly.GetExecutingAssembly();
            var codeBase          = assembly.Location;
            var codeBaseDirectory = Path.GetDirectoryName(codeBase);
            var ant = Path.Combine(codeBaseDirectory, "AntDeployApp.exe");

            using (var process = new System.Diagnostics.Process())
            {
                process.StartInfo.FileName        = ant;
                process.StartInfo.Arguments       = $"\"{projectPramPath}\"";
                process.StartInfo.CreateNoWindow  = false;
                process.StartInfo.WindowStyle     = ProcessWindowStyle.Normal;
                process.StartInfo.UseShellExecute = false;
                process.StartInfo.Verb            = "runas";

                process.Start();

                process.WaitForExit();
            }
        }
Beispiel #2
0
        private void DoAntDeployProcess(string projectPath, ProjectParam param)
        {
            var globalConfig = ProjectHelper.ReadGlobalConfig();

            try
            {
                if (!globalConfig.MultiInstance)
                {
                    StartListeningForWindowChanges();
                }

                var md5             = MD5(projectPath);
                var path            = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var projectPram     = JsonConvert.SerializeObject(param);
                var projectPramPath = Path.Combine(path, md5 + "_param.json");
                File.WriteAllText(projectPramPath, projectPram, Encoding.UTF8);

                var assembly          = Assembly.GetExecutingAssembly();
                var codeBase          = assembly.Location;
                var codeBaseDirectory = Path.GetDirectoryName(codeBase);
                var ant = Path.Combine(codeBaseDirectory, "AntDeployApp.exe");
                using (var process = new Process())
                {
                    process.StartInfo.FileName        = ant;
                    process.StartInfo.Arguments       = $"\"{projectPramPath}\"";
                    process.StartInfo.CreateNoWindow  = false;
                    process.StartInfo.WindowStyle     = ProcessWindowStyle.Normal;
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.Verb            = "runas";
                    process.Start();
                    if (!globalConfig.MultiInstance)
                    {
                        processHIntPtrGet = () =>
                        {
                            try
                            {
                                return(process.MainWindowHandle);
                            }
                            catch (Exception)
                            {
                                return(new IntPtr(0));
                            }
                        };
                    }
                    //var hwndMainWindow = (IntPtr)DTE.MainWindow.HWnd;
                    //SetParent(processHIntPtr, hwndMainWindow);
                    if (!globalConfig.MultiInstance)
                    {
                        process.WaitForExit();
                    }
                }
            }
            finally
            {
                if (!globalConfig.MultiInstance)
                {
                    StopListeningForWindowChanges();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// This function is the callback used to execute a command when the a menu item is clicked.
        /// See the Initialize method to see how the menu item is associated to this function using
        /// the OleMenuCommandService service and the MenuCommand class.
        /// </summary>
        private void MenuItemCallback(object sender, EventArgs e)
        {
            var selectItems = DTE.SelectedItems.OfType <SelectedItem>().Where(x => x.Project != null).Select(x => x.Project).ToArray();

            if (selectItems.Length == 1)
            {
                var project     = selectItems[0];
                var projectFile = project.FullName;
                try
                {
                    Saveall();

                    ProjectParam param = new ProjectParam();
                    param.IsWebProejct     = ProjectHelper.IsWebProject(project);
                    param.IsNetcorePorject = ProjectHelper.IsDotNetCoreProject(project);
                    param.OutPutName       = project.GetProjectProperty("OutputFileName");
                    param.VsVersion        = ProjectHelper.GetVsVersion();
                    try
                    {
                        param.MsBuildPath = new MsBuildHelper().GetMsBuildPath();
                    }
                    catch (Exception)
                    {
                        //ignore
                    }

                    param.ProjectPath = projectFile;
                    if (!string.IsNullOrEmpty(param.MsBuildPath))
                    {
                        param.MsBuildPath = Path.Combine(param.MsBuildPath, "MSBuild.exe");
                    }


                    DoAntDeployProcess(projectFile, param);
                }
                catch (Exception ex)
                {
                    MessageBox(ex.ToString());
                }
            }
            else
            {
                MessageBox("multi projects not supported!");
            }
        }