Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the nupack Package Manager Console to set working folder to solution folder

In Visual Studio, nupack adds a power-shell window called the Package Manager Console. I am thinking that this would be a good place to run source control commands (I'm using Mercurial). However, the default working directory is my users folder, so I need to navigate to my code folder every time I load a new project.

I am wondering if there is a one-line command to set the working directory to the solution folder. e.g. does something like this exist?

cd $SolutionFolder

From the results of get-variable it doens't look like there is anything immediately available, but I've never used powershell before, so maybe there is a way of getting the solution folder?

like image 700
Mark Heath Avatar asked Oct 25 '10 18:10

Mark Heath


People also ask

How do I use package manager console?

To open the Package Manager Console in Visual Studio, select Tools > NuGet Package Manager > Package Manager Console from the top menu.

Where is manage NuGet packages for solution?

Manage packages for the solution Select a solution in Solution Manager, and then select Tools > NuGet Package Manager > Manage NuGet Packages for Solution.

How do I show Package Manager console?

To open the console in Visual Studio, go to the main menu and select Tools > NuGet Package Manager > Package Manager Console command.

What is Package Manager console in Visual Studio?

The NuGet Package Manager Console uses NuGet PowerShell commands to find, install, uninstall, restore, and update NuGet packages. The console is built into Visual Studio on Windows.


1 Answers

Thanks to Doug for pointing me in the right direction. I've written up full instructions on my blog here:

http://mark-dot-net.blogspot.com/2010/10/change-to-solution-folder-in-package.html

The basic answer is that the following command will do it:

Split-Path -parent $dte.Solution.FileName | cd

To make it more readily available, you need to create a function in your "user profile" script file, the location of which is found in the $profile variable. You will need to create the file if it doesn't exist. Then add a function:

Function solutionFolder()
{
    Split-Path -parent $dte.Solution.FileName | cd
} 

Now, after loading a solution in VS2010, you can simply type:

solutionFolder

and the working folder will be changed.

like image 122
Mark Heath Avatar answered Sep 20 '22 05:09

Mark Heath