diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5f65795 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ +Copyright 2015 Mads Kristensen + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/OpenCommandLine.sln b/OpenCommandLine.sln new file mode 100644 index 0000000..4683ed7 --- /dev/null +++ b/OpenCommandLine.sln @@ -0,0 +1,27 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenCommandLine", "src\OpenCommandLine.csproj", "{ADE3EF15-69C4-48AC-ABE1-9C645C992558}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6A2C86AE-EA03-427F-AA05-9403BA3A37A2}" + ProjectSection(SolutionItems) = preProject + LICENSE = LICENSE + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ADE3EF15-69C4-48AC-ABE1-9C645C992558}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ADE3EF15-69C4-48AC-ABE1-9C645C992558}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ADE3EF15-69C4-48AC-ABE1-9C645C992558}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ADE3EF15-69C4-48AC-ABE1-9C645C992558}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/Guids.cs b/src/Guids.cs new file mode 100644 index 0000000..1449e5a --- /dev/null +++ b/src/Guids.cs @@ -0,0 +1,19 @@ +// Guids.cs +// MUST match guids.h +using System; + +namespace MadsKristensen.OpenCommandLine +{ + static class GuidList + { + public const string guidOpenCommandLinePkgString = "f4ab1e64-5d35-4f06-bad9-bf414f4b3bbb"; + public const string guidOpenCommandLineCmdSetString = "59c8a2ef-e017-4f2d-93ee-ca161749897d"; + + public static readonly Guid guidOpenCommandLineCmdSet = new Guid(guidOpenCommandLineCmdSetString); + } + + static class PkgCmdIDList + { + public const uint cmdidOpenCommandLine = 0x100; + } +} \ No newline at end of file diff --git a/src/OpenCommandLine.csproj b/src/OpenCommandLine.csproj new file mode 100644 index 0000000..2982ab2 --- /dev/null +++ b/src/OpenCommandLine.csproj @@ -0,0 +1,177 @@ + + + + 12.0 + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + Debug + AnyCPU + 2.0 + {ADE3EF15-69C4-48AC-ABE1-9C645C992558} + {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + MadsKristensen.OpenCommandLine + OpenCommandLine + false + + + v4.5 + Program + $(DevEnvDir)\devenv.exe + /rootsuffix Exp + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + true + + + true + + + + + + + + + + + + + + + + + {80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2} + 8 + 0 + 0 + primary + False + False + + + {26AD1324-4B7C-44BC-84F8-B86AED45729F} + 10 + 0 + 0 + primary + False + False + + + {1A31287A-4D7D-413E-8E32-3B374931BD89} + 8 + 0 + 0 + primary + False + False + + + {2CE2370E-D744-4936-A090-3FFFE667B0E1} + 9 + 0 + 0 + primary + False + False + + + {1CBA492E-7263-47BB-87FE-639000619B15} + 8 + 0 + 0 + primary + False + False + + + {00020430-0000-0000-C000-000000000046} + 2 + 0 + 0 + primary + False + False + + + + + + + + + + true + VSPackage + + + + + Resources\LICENSE + true + + + Designer + + + + + Menus.ctmenu + + + + + + + + true + + + + true + + + + true + + + + + \ No newline at end of file diff --git a/src/OpenCommandLine.vsct b/src/OpenCommandLine.vsct new file mode 100644 index 0000000..be02677 --- /dev/null +++ b/src/OpenCommandLine.vsct @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/OpenCommandLinePackage.cs b/src/OpenCommandLinePackage.cs new file mode 100644 index 0000000..749709b --- /dev/null +++ b/src/OpenCommandLinePackage.cs @@ -0,0 +1,83 @@ +using System; +using System.ComponentModel.Design; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; +using EnvDTE; +using EnvDTE80; +using Microsoft.VisualStudio.Shell; +using Microsoft.VisualStudio.Shell.Interop; + +namespace MadsKristensen.OpenCommandLine +{ + [PackageRegistration(UseManagedResourcesOnly = true)] + [InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)] + [ProvideMenuResource("Menus.ctmenu", 1)] + [ProvideAutoLoad(UIContextGuids80.SolutionExists)] + [Guid(GuidList.guidOpenCommandLinePkgString)] + public sealed class OpenCommandLinePackage : Package + { + private static DTE2 _dte; + + protected override void Initialize() + { + base.Initialize(); + _dte = GetService(typeof(DTE)) as DTE2; + + OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; + if (null != mcs) + { + CommandID menuCommandID = new CommandID(GuidList.guidOpenCommandLineCmdSet, (int)PkgCmdIDList.cmdidOpenCommandLine); + MenuCommand menuItem = new MenuCommand(OpenCmd, menuCommandID); + mcs.AddCommand(menuItem); + } + } + + private void OpenCmd(object sender, EventArgs e) + { + var path = GetPath(); + + if (string.IsNullOrEmpty(path)) + return; + + ProcessStartInfo start = new ProcessStartInfo("cmd", "/k") + { + WorkingDirectory = path + }; + + var p = new System.Diagnostics.Process(); + p.StartInfo = start; + p.Start(); + } + + private static string GetPath() + { + Project project = GetActiveProject(); + + if (project != null && !string.IsNullOrEmpty(project.FullName)) + return project.Properties.Item("FullPath").Value.ToString(); + + if (_dte.Solution != null && !string.IsNullOrEmpty(_dte.Solution.FullName)) + return Path.GetDirectoryName(_dte.Solution.FullName); + + return null; + } + + public static Project GetActiveProject() + { + try + { + Array activeSolutionProjects = _dte.ActiveSolutionProjects as Array; + + if (activeSolutionProjects != null && activeSolutionProjects.Length > 0) + return activeSolutionProjects.GetValue(0) as Project; + } + catch (Exception ex) + { + Debug.Write(ex.Message); + } + + return null; + } + } +} diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e00737c --- /dev/null +++ b/src/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System; +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Open Command Line")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Mads Kristensen")] +[assembly: AssemblyProduct("Open Command Line")] +[assembly: AssemblyCopyright("")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: ComVisible(false)] +[assembly: CLSCompliant(false)] +[assembly: NeutralResourcesLanguage("en-US")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: + +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] + + + diff --git a/src/Resources/Images.png b/src/Resources/Images.png new file mode 100644 index 0000000..9916c8d Binary files /dev/null and b/src/Resources/Images.png differ diff --git a/src/Resources/Package.ico b/src/Resources/Package.ico new file mode 100644 index 0000000..449296f Binary files /dev/null and b/src/Resources/Package.ico differ diff --git a/src/Resources/icon.png b/src/Resources/icon.png new file mode 100644 index 0000000..7b7cc17 Binary files /dev/null and b/src/Resources/icon.png differ diff --git a/src/Resources/preview.png b/src/Resources/preview.png new file mode 100644 index 0000000..88a8230 Binary files /dev/null and b/src/Resources/preview.png differ diff --git a/src/VSPackage.resx b/src/VSPackage.resx new file mode 100644 index 0000000..74563ff --- /dev/null +++ b/src/VSPackage.resx @@ -0,0 +1,140 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + Open Command Line + + + Opens a command line (cmd) at the root of the project + + + Resources\Package.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/src/source.extension.vsixmanifest b/src/source.extension.vsixmanifest new file mode 100644 index 0000000..2373591 --- /dev/null +++ b/src/source.extension.vsixmanifest @@ -0,0 +1,22 @@ + + + + + OpenCommandLine + Opens a command line (cmd) at the root of the project + Resources\LICENSE + Resources\icon.png + Resources\preview.png + + + + + + + + + + + + +