Exemplo n.º 1
0
        private void SetupProcess(string command, string arguments)
        {
            Options options = GetDialogPage(typeof(Options)) as Options;
            string  folder  = VsHelpers.GetFolderPath(options, _dte);

            StartProcess(folder, command, arguments);
        }
Exemplo n.º 2
0
        void BeforeExeQuery(object sender, EventArgs e)
        {
            OleMenuCommand button = (OleMenuCommand)sender;

            button.Enabled = button.Visible = false;
            var item = VsHelpers.GetProjectItem(_dte);

            if (item == null || item.FileCount == 0)
            {
                button.Enabled = button.Visible = false;
                return;
            }

            string path = item.FileNames[1];

            if (!VsHelpers.IsValidFileName(path))
            {
                return;
            }

            string[] allowed   = new[] { ".CMD", ".BAT" };
            string   ext       = Path.GetExtension(path).ToUpperInvariant();
            bool     isEnabled = allowed.Contains(ext) && File.Exists(path);

            button.Enabled = button.Visible = isEnabled;
        }
Exemplo n.º 3
0
        private void OpenPowershell(object sender, EventArgs e)
        {
            Options options = GetDialogPage(typeof(Options)) as Options;
            string  folder  = VsHelpers.GetFolderPath(options, _dte);

            StartProcess(folder, "powershell.exe", "");
        }
        private void OpenCmd(object sender, EventArgs e)
        {
            string installDir    = VsHelpers.GetInstallDirectory(this);
            string devPromptFile = Path.Combine(installDir, @"..\Tools\VsDevCmd.bat");

            SetupProcess("cmd.exe", "/k \"" + devPromptFile + "\"");
        }
Exemplo n.º 5
0
        void BeforeExeQuery(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var button = (OleMenuCommand)sender;

            button.Enabled = button.Visible = false;
            ProjectItem item = VsHelpers.GetProjectItem(_dte);

            if (item == null || item.FileCount == 0)
            {
                return;
            }

            string path = item.FileNames[1];

            if (!VsHelpers.IsValidFileName(path))
            {
                return;
            }

            string[] allowed   = { ".CMD", ".BAT", ".PS1" };
            string   ext       = Path.GetExtension(path);
            bool     isEnabled = allowed.Contains(ext, StringComparer.OrdinalIgnoreCase) && File.Exists(path);

            button.Enabled = button.Visible = isEnabled;
        }
Exemplo n.º 6
0
        private void ExecuteFile(object sender, EventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            ProjectItem item   = VsHelpers.GetProjectItem(_dte);
            string      path   = item.FileNames[1];
            string      folder = Path.GetDirectoryName(path);

            string ext = Path.GetExtension(path);

            if (!string.IsNullOrEmpty(ext) && ext.ToLower() == ".ps1")
            {
                StartProcess(folder, "powershell.exe", "-ExecutionPolicy Bypass -NoExit -File \"" + Path.GetFileName(path) + "\"");
            }
            else
            {
                var    options   = GetDialogPage(typeof(Options)) as Options;
                string arguments = (options.Arguments ?? string.Empty).Replace("%folder%", folder);

                string confName = VsHelpers.GetSolutionConfigurationName(_dte);
                arguments = arguments.Replace("%configuration%", confName);

                string confPlatform = VsHelpers.GetSolutionConfigurationPlatformName(_dte);
                arguments = arguments.Replace("%platform%", confPlatform);

                arguments = arguments.Replace("%file%", Path.GetFileName(path));

                StartProcess(folder, options.Command, arguments);
            }
        }
        private void OpenCustom(object sender, EventArgs e)
        {
            Options options   = GetDialogPage(typeof(Options)) as Options;
            string  folder    = VsHelpers.GetFolderPath(options, _dte);
            string  arguments = (options.Arguments ?? string.Empty).Replace("%folder%", folder);

            StartProcess(folder, options.Command, arguments);
        }
        private void ExecuteFile(object sender, EventArgs e)
        {
            var    item   = VsHelpers.GetProjectItem(_dte);
            string path   = item.FileNames[1];
            string folder = Path.GetDirectoryName(path);

            StartProcess(folder, "cmd.exe", "/k \"" + Path.GetFileName(path) + "\"");
        }
Exemplo n.º 9
0
        private void SetupProcess(string command, string arguments)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var    options = GetDialogPage(typeof(Options)) as Options;
            string folder  = VsHelpers.GetFolderPath(options, _dte);

            StartProcess(folder, command, arguments);
        }
Exemplo n.º 10
0
        private void OpenCmd(object sender, EventArgs e)
        {
            Options options = GetDialogPage(typeof(Options)) as Options;
            string  folder  = VsHelpers.GetFolderPath(options, _dte);

            string installDir    = VsHelpers.GetInstallDirectory(this);
            string devPromptFile = Path.Combine(installDir, @"..\Tools\VsDevCmd.bat");

            StartProcess(folder, "cmd.exe", "/k \"" + devPromptFile + "\"");
        }
Exemplo n.º 11
0
        public override void LoadSettingsFromStorage()
        {
            _isLoading = true;

            base.LoadSettingsFromStorage();

            if (string.IsNullOrEmpty(Command))
            {
                Command = "cmd.exe";
            }

            if (string.IsNullOrEmpty(FriendlyName))
            {
                FriendlyName = "Default (cmd)";
            }

            if (string.IsNullOrEmpty(Preset))
            {
                Preset = "cmd";
            }

            if (DefaultPresets.Count == 0)
            {
                string installDir    = VsHelpers.GetInstallDirectory();
                string devPromptFile = Path.Combine(installDir, @"..\Tools\VsDevCmd.bat");

                DefaultPresets["cmd"]            = new Command("cmd.exe");
                DefaultPresets["Dev Cmd Prompt"] = new Command("cmd.exe", "/k \"" + devPromptFile + "\"");
                DefaultPresets["PowerShellCore"] = new Command("pwsh.exe", "-ExecutionPolicy Bypass -NoExit");
                DefaultPresets["PowerShell"]     = new Command("powershell.exe", "-ExecutionPolicy Bypass -NoExit");
                DefaultPresets["PowerShell ISE"] = new Command("powershell_ise.exe");
                DefaultPresets["posh-git"]       = new Command("powershell.exe", @"-ExecutionPolicy Bypass -NoExit -Command .(Resolve-Path ""$env:LOCALAPPDATA\GitHub\shell.ps1""); .(Resolve-Path ""$env:github_posh_git\profile.example.ps1"")");
                DefaultPresets["Git Bash"]       = new Command(@"C:\Program Files\Git\git-bash.exe");
                DefaultPresets["Babun"]          = new Command(@"%UserProfile%\.babun\cygwin\bin\mintty.exe", "/bin/env CHERE_INVOKING=1 /bin/zsh.exe");

                string GitHubForWindowsPath = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "GitHub", "GitHub.appref-ms");
                if (File.Exists(GitHubForWindowsPath))
                {
                    DefaultPresets["GitHub Console"] = new Command(@"%LOCALAPPDATA%\GitHub\GitHub.appref-ms", "-open-shell");
                }

                DefaultPresets["cmder"]  = new Command("cmder.exe", "/START \"%folder%\"");
                DefaultPresets["ConEmu"] = new Command("ConEmu64.exe", "/cmd PowerShell.exe");
                DefaultPresets["Custom"] = new Command(string.Empty, string.Empty);
            }

            _isLoading = false;
        }
Exemplo n.º 12
0
        private void OpenCustom(object sender, EventArgs e)
        {
            var    options   = GetDialogPage(typeof(Options)) as Options;
            string folder    = VsHelpers.GetFolderPath(options, _dte);
            string arguments = (options.Arguments ?? string.Empty).Replace("%folder%", folder);

            string confName = VsHelpers.GetSolutionConfigurationName(_dte);

            arguments = arguments.Replace("%configuration%", confName);

            string confPlatform = VsHelpers.GetSolutionConfigurationPlatformName(_dte);

            arguments = arguments.Replace("%platform%", confPlatform);

            StartProcess(folder, options.Command, arguments);
        }
        private void ExecuteFile(object sender, EventArgs e)
        {
            var    item   = VsHelpers.GetProjectItem(_dte);
            string path   = item.FileNames[1];
            string folder = Path.GetDirectoryName(path);

            string ext = Path.GetExtension(path);

            if (!string.IsNullOrEmpty(ext) && ext.ToLower() == ".ps1")
            {
                StartProcess(folder, "powershell.exe", "-ExecutionPolicy Bypass -NoExit -File \"" + Path.GetFileName(path) + "\"");
            }
            else
            {
                StartProcess(folder, "cmd.exe", "/k \"" + Path.GetFileName(path) + "\"");
            }
        }
Exemplo n.º 14
0
        private void OpenCustom(object sender, EventArgs e)
        {
            Options options = GetDialogPage(typeof(Options)) as Options;

            if (IsCustomSameAsCmd(options))
            {
                OpenCmd(sender, e);
                return;
            }

            string folder = VsHelpers.GetFolderPath(options, _dte);

            string arguments = options.Arguments;

            if (!string.IsNullOrWhiteSpace(options.FolderPathReplacementToken))
            {
                arguments = arguments.Replace(options.FolderPathReplacementToken, folder);
            }

            StartProcess(folder, options.Command, arguments);
        }
Exemplo n.º 15
0
        public override void LoadSettingsFromStorage()
        {
            _isLoading = true;

            base.LoadSettingsFromStorage();

            if (string.IsNullOrEmpty(Command))
            {
                Command = "cmd.exe";
            }

            if (string.IsNullOrEmpty(Preset))
            {
                Preset = "cmd";
            }

            if (DefaultPresets.Count == 0)
            {
                string installDir    = VsHelpers.GetInstallDirectory(ServiceProvider.GlobalProvider);
                string devPromptFile = Path.Combine(installDir, @"..\Tools\VsDevCmd.bat");

                DefaultPresets["cmd"]            = new Command("cmd.exe");
                DefaultPresets["Dev Cmd Prompt"] = new Command("cmd.exe", "/k \"" + devPromptFile + "\"");
                DefaultPresets["PowerShell"]     = new Command("powershell.exe", "-ExecutionPolicy Bypass -NoExit");
                DefaultPresets["posh-git"]       = new Command("powershell.exe", @"-ExecutionPolicy Bypass -NoExit -Command .(Resolve-Path ""$env:LOCALAPPDATA\GitHub\shell.ps1""); .(Resolve-Path ""$env:github_posh_git\profile.example.ps1"")");

                string GitHubForWindowsPath = Path.Combine(Environment.GetEnvironmentVariable("LocalAppData"), "GitHub", "GitHub.appref-ms");
                if (File.Exists(GitHubForWindowsPath))
                {
                    DefaultPresets["GitHub Console"] = new Command(@"%LOCALAPPDATA%\GitHub\GitHub.appref-ms", "-open-shell");
                }

                DefaultPresets["cmder"]  = new Command("cmder.exe", "/START %folder%");
                DefaultPresets["Custom"] = new Command(string.Empty, string.Empty);
            }

            _isLoading = false;
        }