I would like to create a macro in Visual Studio 2010 which:
-opens the Package Manager Console
-runs a command in it
The macro recording tool only generates the code for the first issue:
DTE.ExecuteCommand("View.PackageManagerConsole")
Any thoughts on how to inject and run a command?
Many thanks.
Try this : http://msdn.microsoft.com/en-us/library/a0003t62(v=vs.100).aspx
Somethimes, it is helpful, ot try searching in google with subject: Run Macro in VS 2010
Related
This is my first post:) Nice to get help
Is there any option to do that?
I attached screenshot
You can install PowerShell tools for Visual Studio.
You could install it from Visual Studio gallery. Once installed,
Create a new project , you will see PowerShell listed like below.
Below blog series will walk you though it.
https://pleasereleaseme.net/getting-started-with-powershell-tools-for-visual-studio/
The majority of .NET core tutorials online seem to use Visual Studio code, rather than Visual Studio (Full fat? Is there a proper term for the full version? I use Professional but there is also Community, Enterprise etc).
These tutorials make the most of the integrated terminal within VS code for running dotnet command line commands (dotnet new, dotnet build etc).
I am struggling to find where to execute these commands in Visual Studio. Where is the right place to do this? I have .NET core SDK installed.
I have seen some suggestions for the package manager console - although this seems odd, why should I be running dotnet commands via a "package manager console"?
Update: Visual Studio 2019 16.6 now has it's own Terminal (Hoorray!). Check View -> Terminal or try to press Ctrl + `.
Old answer:
There are extensions for that. I tried BuiltinCmd and Whack Whack Terminal, the latter worked better for me. You can choose between CMD and PowerShell, all dotnet CLI commands works just fine.
The full version of Visual Studio is "Visual Studio", "Code" is what differentiates "Visual Studio Code".
As far as an integrated command line inside Visual Studio goes, the Package Manager Console is it. It's basically just powershell, with some addins from Visual Studio and any extensions or NuGet packages you have installed. It gets its name from the fact that it was introduced specifically for the management of NuGet packages, but was quickly co-opted by things like Entity Framework, and just continued to grow from there. Admittedly, Microsoft should probably consider rebranding it, but there's so much documentation, articles and tutorials out there that reference the "Package Manager Console", that it would probably actually create more confusion if they renamed it.
While you can run dotnet commands through it, I'd imagine the results would be a bit unpredictable. Perhaps I'm wrong here, as I've never even tried to do things like dotnet new from the PMC, but the PMC is not really directory-based like a traditional console window. It's more contextual in nature, applying commands to target projects. I do know that things like dotnet restore and such work fine, and dotnet new may as well. You'll just have to try it.
That said, I tend to take an all or nothing approach with Visual Studio. It's a beast, and if you're going to install it and use it, you might as well use it. You can do everything you can do with dotnet through the GUI. And, for those few times where you might need something special, you can pop a console window. If you want to do everything with dotnet, Visual Studio quickly becomes overkill, and Visual Studio Code would probably be much more efficient for your workflow.
While following a tutorial to update database, I had to run these commands
dotnet ef migrations add MaxLengthOnNames
dotnet ef database update
in the command window of Visual studio, as per tutorial. When I opened this window in visual studio (View > Other Windows > Command Window) and attempted to run these commands, I received this error:
>dotnet ef migrations add MaxLengthOnNames
Command "dotnet" is not valid.
>dotnet ef database update
Command "dotnet" is not valid.
>
When I attempted to run them in Package Manager Console, this is the result I got:
No project was found. Change the current working directory or use the --project option.
Now, I googled it a bit and got the hint that I must run these commands in windows command prompt (opened by typing "cmd" in Windows start search). Steps are:
Open windows command prompt
Set your project directory as current directory
run any dotnet command you need like I entered this: dotnet ef database update
success
I'm not sure what version of Visual Studio it was added, but Tools ... Command Line ... Developer Command Prompt will open a command prompt for you at your solution's root. From there, cd into the project you want to run and then dotnet run.
Also, if your version of Visual Studio doesn't have that menu option preinstalled, you can add it as an "External Tool" pretty easily: link
Tools -> Command Line -> Developer Powershell
You can execute cmdlets in the Visual Studio Package Manager Console that are functionally equivalent to at least some of the dotnet commands.
For example, there is a suite of cmdlets you can call that are equivalent to the dotnet ef commands. See here: https://learn.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell
So the equivalent of dotnet ef migrations add MaxLengthOnNames in the Package Manager Console is Add-Migration MaxLengthOnNames.
And the equivalent of dotnet ef database update in the Package Manager Console is Update-Database.
Using that page I linked to it should be fairly easy to figure out the cmdlet equivalents of the remaining dotnet ef commands.
I don't know about dotnet run though.
Installing Visual Studio Code extensions from the command line is very simple is very simple. But lots of extensions require additional configuration to work.
Example: https://github.com/shanalikhan/code-settings-sync#upload-your-settings-for-the-first-time
We have to open the command palette, type a specific command, the paste a Gist ID and hit Enter. Only then the extension can work.
Another example: https://github.com/wakatime/vscode-wakatime#installation
Here we have to restart/reload VSCode and then enter an API key before the installation is actually finished.
How can Visual Studio Code extensions be configured from the command line?
Got a reply on one of the extension's Github that this is not possible right now:
Currently its Limitation from Code, editor doesnt allow extension to perform actions from CLI
https://github.com/shanalikhan/code-settings-sync/issues/465#issuecomment-349903682
The related issue for Visual Studio Code was closed :(
I searched for an extension but I didn't find any consoles, I only found Terminals, which solves the problem but only when I'm running without debugging which is almost useless.
There are two extension tools in VS IDE called Open Command Line and PowerConsole
You could check them in your VS, it would help us to visit or run project file or command lines.
I'm cheap and don't want to pay for ReSharper or TestDriven.NET, is there a free visual Studio addin for NUnit?
You can create a blank project (Choose console application for example) and in the property of the project you can select DEBUG tag and select "Start External Program". Put the path of Nunit. Then, in the start option, the command line arguments select the DLL that contains all your tests (mine is always in the nunit\bin...). Then select "enable unmanaged code debugging" and you will be able to start the project inside VS and even use the debugger step-by-step.
This is a free solution.
Now you can use Gallio: it's open source. www.gallio.org
By the way TestDriven can be downloaded for free if it's for personal use or Open Source project.
I had to find a way to use .Net Reflector inside VS few days ago and when I downloaded TestDriven it cames with. Never got any popup asking me to paid.
NUnit actually ships with a basic integrated runner. It's not very good, and not very publicized, but unless Charlie has taken it out, it should be in the source.
I know this is an old question but another way to do this is to add an external tool from the tools menu to run nunit - set the arguments to be $(TargetName)$(TargetExt) and initial directory to $(ProjectDir)\bin\Debug
check out this link
This is an old question and things have changed since the answer was accepted.
You may try NCrunch to run tests automatically or manually.
If you're running Visual Studio 2012, there is a plugin written by Charlie Poole, one of the NUnit contributers, that makes use of the new Visual Studio Unit testing plugins.
Download VsTestAdapater - it's also in the extension manager.
Unfortunately it doesn't have much grouping options yet, either by run/not run - so you can't group by class, solution and so on. It also doesn't show you any stacktrace if a test fails, just a simple green tick or red box and a message.
I haven't used it, but NUnitit is a free Visual Studio Add-in for NUnit.
http://nunitit.codeplex.com
From my experience, the best add-in for visual studio is resharper. TestDriven.Net is also good for unit tests. Hope that helps
Also found this one : http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099
It is able to launch your tests in debugger, however you need to recompile the code manually each time you change something - no auto run-build integration