Exemplo n.º 1
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //ThreadHelper.ThrowIfNotOnUIThread();
            // 右键点击后选中的文件夹(一般是一个,但也可以多个)
            var selectedDirs = ProjectHelpers.GetSelectedItemPaths();

            if (selectedDirs.Count() == 0)
            {
                OutPutInfo.Info("未选中文件夹!"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                OutPutInfo.Info("未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                OutPutInfo.Info(res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>();

            foreach (string dirPath in selectedDirs)
            {
                // 选中的可能是文件和目录,如果是目录才取出其中文件和子目录文件
                if (Directory.Exists(dirPath))
                {
                    srcfiles.AddRange(Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories));
                }
            }
            if (srcfiles.Count == 0)
            {
                OutPutInfo.Info("至少选择一个文件夹!");
                return;
            }
            // 发布处理
            // 发布处理
            Task.Factory.StartNew(() =>
            {
                string resinfo = PublishHelpers.PublishFiles(srcfiles);
                if (resinfo != null)
                {
                    OutPutInfo.Info(resinfo);
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //ThreadHelper.ThrowIfNotOnUIThread();
            // 右键点击后选中的文件(一般是一个,但也可以多个)
            var items = ProjectHelpers.GetSelectedItemPaths();

            if (items.Count() == 0)
            {
                OutPutInfo.Info("未选中文件!"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                OutPutInfo.Info("未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                OutPutInfo.Info(res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>();

            foreach (string path in items)
            {
                // 可能选中的是目录
                if (File.Exists(path))
                {
                    srcfiles.Add(path);
                }
            }
            if (srcfiles.Count == 0)
            {
                OutPutInfo.Info("至少选择一个文件!");
                return;
            }
            // 发布处理
            Task.Factory.StartNew(() =>
            {
                string resinfo = PublishHelpers.PublishFiles(srcfiles);
                if (resinfo != null)
                {
                    OutPutInfo.Info(resinfo);
                }
            });
        }
Exemplo n.º 3
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //var button = (MenuCommand)sender;
            // 右键点击后选中的文件(一般是一个,但也可以多个)
            var items = ProjectHelpers.GetSelectedItemPaths();

            if (items.Count() == 0)
            {
                ErrBox.Info(this.package, "未选中文件!"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                ErrBox.Info(this.package, "未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                ErrBox.Info(this.package, res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>();

            foreach (string path in items)
            {
                // 可能选中的是目录
                if (File.Exists(path))
                {
                    srcfiles.Add(path);
                }
            }
            if (srcfiles.Count == 0)
            {
                ErrBox.Info(this.package, "至少选择一个文件!");
                return;
            }
            // 发布处理
            string resinfo = PublishHelpers.PublishFiles(srcfiles);

            if (resinfo != null)
            {
                ErrBox.Info(this.package, resinfo);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //var button = (MenuCommand)sender;
            // 右键点击后选中的文件夹(一般是一个,但也可以多个)
            var selectedDirs = ProjectHelpers.GetSelectedItemPaths();
            if (selectedDirs.Count() == 0)
            {
                ErrBox.Info(this.package, "未选中文件夹!"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();
            if (activeProj == null)
            {
                ErrBox.Info(this.package, "未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();
            if (res != null)
            {
                ErrBox.Info(this.package, res); return;
            }

            // 取得要发布的文件路径 
            List<string> srcfiles = new List<string>();
            foreach (string dirPath in selectedDirs)
            {
                // 选中的可能是文件和目录,如果是目录才取出其中文件和子目录文件
                if (Directory.Exists(dirPath))
                    srcfiles.AddRange(Directory.GetFiles(dirPath, "*", SearchOption.AllDirectories));
            }
            if (srcfiles.Count == 0)
            {
                ErrBox.Info(this.package, "至少选择一个文件夹!");
                return;
            }
            // 发布处理
            string resinfo = PublishHelpers.PublishFiles(srcfiles);
            if (resinfo != null)
            {
                ErrBox.Info(this.package, resinfo);
            }
        }
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //ThreadHelper.ThrowIfNotOnUIThread();
            // 发布当前处于活动状态的1个文件 如果没有活动文件,不动作
            var activedoc = ProjectHelpers.GetActiveDoc();

            if (activedoc == null)
            {
                OutPutInfo.Info("未找到激活的文件"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                OutPutInfo.Info("未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                OutPutInfo.Info(res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>
            {
                activedoc.FullName
            };

            // 发布处理
            Task.Factory.StartNew(() =>
            {
                string resinfo = PublishHelpers.PublishFiles(srcfiles);
                if (resinfo != null)
                {
                    OutPutInfo.Info(resinfo);
                }
            });
        }
Exemplo n.º 6
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            // 发布当前处于活动状态的1个文件 如果没有活动文件,不动作
            var activedoc = ProjectHelpers.GetActiveDoc();

            if (activedoc == null)
            {
                ErrBox.Info(this.package, "未找到激活的文件"); return;
            }

            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                ErrBox.Info(this.package, "未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                ErrBox.Info(this.package, res); return;
            }

            // 取得要发布的文件路径
            List <string> srcfiles = new List <string>
            {
                activedoc.FullName
            };
            // 发布处理
            string resinfo = PublishHelpers.PublishFiles(srcfiles);

            if (resinfo != null)
            {
                ErrBox.Info(this.package, resinfo);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// This function is the callback used to execute the command when the menu item is clicked.
        /// See the constructor to see how the menu item is associated with this function using
        /// OleMenuCommandService service and MenuCommand class.
        /// </summary>
        /// <param name="sender">Event sender.</param>
        /// <param name="e">Event args.</param>
        private void Execute(object sender, EventArgs e)
        {
            //ThreadHelper.ThrowIfNotOnUIThread();
            // 当前活动项目路径
            Project activeProj = ProjectHelpers.GetActiveProject();

            if (activeProj == null)
            {
                OutPutInfo.Info("未选中WEB项目"); return;
            }
            // 建立发布配置对象
            EnvVar.ProjectDir = activeProj.GetRootFolder();
            string res = PublishHelpers.CreatePublishCfg();

            if (res != null)
            {
                OutPutInfo.Info(res); return;
            }

            // 发布前删除发布目录下所有文件(根据配置文件的设置而执行)
            string emptyOutDir = PublishHelpers.EmptyPuslishDir();

            if (emptyOutDir != null)
            {
                OutPutInfo.Info(emptyOutDir); return;
            }

            //
            OutPutInfo.VsOutWind("<<<--发布项目-->>>" + Environment.NewLine, true);

            // 如果要发布bin目录,才编译项目
            if (PublishHelpers.JsonCfg.BuildBin == true)
            {
                // 编译项目. buildCfg : debug和release.取自当前选中的编译选项
                string buildCfg = activeProj.ConfigurationManager.ActiveConfiguration.ConfigurationName;
                EnvVar._dte.Solution.SolutionBuild.BuildProject(buildCfg, activeProj.UniqueName, true);
                // 编译后DLL文件所在目录.是一个相对于项目根目录起始的目录
                string outBinDir = activeProj.ConfigurationManager.ActiveConfiguration.Properties.Item("OutputPath").Value.ToString().Replace('\\', '/').Trim('/');

                // 复制dll文件到目标目录
                string resBin = PublishHelpers.PublishBin(outBinDir);
                if (resBin != null)
                {
                    OutPutInfo.Info(resBin); return;
                }
            }

            // 发布项目文件
            // 取得项目中所有文件
            List <string> srcfiles = activeProj.GetItems();

            if (srcfiles.Count == 0)
            {
                OutPutInfo.Info("未发布文件,没有找到适合发布的文件.");
                return;
            }

            // 发布处理
            Task.Factory.StartNew(() =>
            {
                string resinfo = PublishHelpers.PublishFiles(srcfiles);
                if (resinfo != null)
                {
                    OutPutInfo.Info(resinfo);
                }
            });
        }