Debugging a PowerShell provider is non-trivial because you must run a 32-bit version of powershell, and you must register the provider in an administrator shell. Do the following steps to get yourself all setup.

  1. Clone the Mercurial repository and place it somewhere on your disk. When dealing with ROOT I like to keep spaces out of the path if at all possible, though for this project it shouldn’t matter.
  2. Make sure you have NuGet installing in VS2010.
  3. In visual studio add the NuGet feed for the ROOT.NET wrappers (PowerShell is all .NET 4.0).
  4. Start up VS2010 and open the PSPROOF project. All the NuGet libraries should come down. If not, use the NuGet command line to fetch them.
  5. Make sure you are building the Debug/x86 version (you have to build x86 because ROOT on windows is 32 bit only).
  6. To register the provider, start up an x86 version of PowerShell, and make the build output directory your local directory (this path will have x86 in it somewhere, probably). Once there, execute the install.ps1 script. Exit the shell.
  7. Back in VS2010, right click on the PSPROOFUtils project and select Properties
  8. Under the Debug tag fill in the Start external program with C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe. Note the SysWOW64 – this forces the debugger to run in x86 mode rather than its preferred x64 mode.
  9. Now, run the debugger. The 32 bit version of powershell should start in the build directory. Check by making sure that powershell responds with 4 when you type “[IntPtr]::Size”.
  10. Run installer.ps1 to enable the addin (it is basically running the command Add-PSnapIn). It will also warn you if you’ve not completed the above registration correctly.

You have to repeat step 10 each time you run the debugger.

Oh, you have to uninstall the snapin if you want to change the location where you are building it! Sad smile: installutil /u .\PSPROOFUtils.dll

Last edited Apr 29, 2012 at 9:37 AM by gwatts, version 3


No comments yet.