After posting my useful one liners, I started thinking about ways to bake the functions into VS without having to copy and paste from my OneNote all the time. I remembered that powershell had profile scripts that run at the start just like most linux shells.
In order to add a profile to the Package Manager Console, create a file called NuGet_profile.ps1 in the C:\Users\
# Copy the NuGet_profile.ps1 file to (the folder may not exist): # # C:\Users\<username>\Documents\WindowsPowerShell\NuGet_profile.ps1 function DebugWeb() { $dte.Debugger.LocalProcesses | ? { ($_.Name -match ".*(w3wp|WebDev.WebSe.*)\.exe$") } | % { $_.Attach() }; }
If you have project specific functions you can create separate scripts for each function and save them to the solution directory. Since the console's default directory is the solution folder, all of the scripts are at your fingertips.
As a bonus, adding the setVSVars function that I introduced in [[Powershell Unlock File In TFS Using Visual Studio Command Line Vars]], with a simple change, I can add functionality that will restore focus to the current window. I highlighted the additions and left in a couple lines (11, 12) which show other ways to access windows inside Visual Studio.
function set-VSVars() { $activeWindow = $dte.ActiveWindow; #Set Visual Studio Command Prompt environment variables`n pushd "c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC"; cmd /c "vcvarsall.bat&set" | ? { $_ -match "^(?<Name>[^=]+)=(?<Value>.+)$" } | % { Set-Item -Force -Path "ENV:\$($matches['Name'])" -Value $matches["Value"]; } popd; Write-Host "Visual Studio 2010 Command Prompt variables set." -ForegroundColor Yellow; #$dte.Windows | ? { $_.Caption -eq "Package Manager Console" } | % { $_.Activate(); } #$dte.Windows.Item("Package Manager Console").Activate(); $activeWindow.Activate(); }
This is useful if you need access to Visual Studio Command Line functions.
No comments:
Post a Comment