Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running powershell script from solution explorer inside Nuget Package Manager Console

I have a few powershell scripts inside my c# project. I added them to a solution folder. Would it be possible to make VS2010 run them inside the nuget powershell console by one of these methods :

  • double clicking on the file
  • right click / open with
  • custom action on the context menu
like image 473
rekna Avatar asked Dec 21 '10 10:12

rekna


People also ask

How do I call a PowerShell script from Visual Studio?

Once it is saved as a PS1, VS Code will identify the file as a PowerShell script. From there, you can execute the PowerShell script by press F5 . You can also click the Run button on the top right of the editor. To run a select, you can press F8 or right click on the selection and click the Run Selection option.

How do I run a PS1 file in Visual Studio?

Solution Folder If you open a PS1 file, you will be able to run it by pressing F5 or by clicking the Start button.


2 Answers

Since the previous answer was posted this very simple package came about which does exactly what is needed:

  • http://lostechies.com/matthinze/2012/01/05/solutionscripts-little-scripts-for-the-nuget-console/
  • https://bitbucket.org/mhinze/solutionscripts/src/d3651b843e3d/tools/init.ps1
  • http://nuget.org/packages/solutionscripts

In short, install the package and place those scripts in a folder called SolutionScripts.

like image 174
Generic Error Avatar answered Sep 28 '22 15:09

Generic Error


We followed up on this question at http://nuget.codeplex.com/Thread/View.aspx?ThreadId=239161.

To summarize, try using an init.ps1 file. Look at the MvcScaffold package for a good example of this.

like image 22
David Ebbo Avatar answered Sep 28 '22 13:09

David Ebbo