Does AnyOne Know how to Debug SharePointPnP.PowerShell

Iron Contributor

I am using VS2017.

I have downloaded into the same level, but diferent directories, in my GitHub Repro, SharePointPnP.PowerShell and OfficeDevPnP.Core and compiled both in Debug Mode.

I have attached to all of the PowerShell processes I can find.

I have put breakpoints in GetFeature.cs and PnPWebRetrievalsCmdlet.cs.

I have run Get-PnPFeature -Scope Web -Web https://xxxxx.sharepoint.com/collaboration

The above command fails "File Not Found" but no breakpoints were hit.

I repeat with command Get-PnPFeature -Scope Web -Web Collaboration.

This command works but still no breakpoints hit.

 

HAve I missed anything ?

4 Replies

Hi @Nigel Price,

 

How are you running your PowerShell commands?

 

I find deugging the easiest by running PowerShell in Visual Studio's PowerShell Interactive Window. Then simply connect your debugger to: PowerShellToolsProcessHost.

 

Then as long as your running code and source code match the debugger will pick up the breakpoints.

Hi @Pieter Veenstra

 

I was running the PowerShell from a PowerShell Window on the same VM as VS2017 is running.

I am trying to get the PowerShell Interactive Window displayingin VS2017, but no joy. (Cntrl  + SHIFT + \).

The SharePointPnP.PowerShell.Commands Project is running in debug mode.

 

Regards

 

Nigel

 

 

Hi,

 

Make sure that type of code is set to "Managed v4.6..." not "Script" when attaching debugger.

It may be attached to "Script" type automatically, then need to change to Manual type selection

__

Br, Ivan

Hi @Ivan Vagunin

 

Thank you very much !

 

That was the problem.

 

Thanks

 

Nigel