Does AnyOne Know how to Debug SharePointPnP.PowerShell

%3CLINGO-SUB%20id%3D%22lingo-sub-52693%22%20slang%3D%22en-US%22%3EDoes%20AnyOne%20Know%20how%20to%20Debug%20SharePointPnP.PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52693%22%20slang%3D%22en-US%22%3E%3CP%3EI%20am%20using%20VS2017.%3C%2FP%3E%3CP%3EI%20have%20downloaded%26nbsp%3Binto%20the%20same%20level%2C%20but%20diferent%20directories%2C%20in%20my%20GitHub%20Repro%2C%20SharePointPnP.PowerShell%20and%20OfficeDevPnP.Core%20and%20compiled%20both%20in%20Debug%20Mode.%3C%2FP%3E%3CP%3EI%20have%20attached%20to%20all%20of%20the%20PowerShell%20processes%20I%20can%20find.%3C%2FP%3E%3CP%3EI%20have%20put%20breakpoints%20in%20GetFeature.cs%20and%20PnPWebRetrievalsCmdlet.cs.%3C%2FP%3E%3CP%3EI%20have%20run%20Get-PnPFeature%20-Scope%20Web%20-Web%20%3CA%20href%3D%22https%3A%2F%2Fxxxxx.sharepoint.com%2Fcollaboration%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fxxxxx.sharepoint.com%2Fcollaboration%3C%2FA%3E%3C%2FP%3E%3CP%3EThe%20above%20command%20fails%20%22File%20Not%20Found%22%20but%20no%20breakpoints%20were%20hit.%3C%2FP%3E%3CP%3EI%20repeat%20with%20command%20Get-PnPFeature%20-Scope%20Web%20-Web%20Collaboration.%3C%2FP%3E%3CP%3EThis%20command%20works%20but%20still%20no%20breakpoints%20hit.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHAve%20I%20missed%20anything%20%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-52693%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPnP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-53750%22%20slang%3D%22en-US%22%3ERe%3A%20Does%20AnyOne%20Know%20how%20to%20Debug%20SharePointPnP.PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-53750%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F6209%22%20target%3D%22_blank%22%3E%40Ivan%20Vagunin%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20very%20much%20!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20was%20the%20problem.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENigel%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-53733%22%20slang%3D%22en-US%22%3ERe%3A%20Does%20AnyOne%20Know%20how%20to%20Debug%20SharePointPnP.PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-53733%22%20slang%3D%22en-US%22%3E%3CP%3EHi%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMake%20sure%20that%20type%20of%20code%20is%20set%20to%20%22Managed%20v4.6...%22%20not%20%22Script%22%20when%20attaching%20debugger.%3C%2FP%3E%3CP%3EIt%20may%20be%20attached%20to%20%22Script%22%20type%20automatically%2C%20then%20need%20to%20change%20to%20Manual%20type%20selection%3C%2FP%3E%3CP%3E__%3C%2FP%3E%3CP%3EBr%2C%20Ivan%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-52723%22%20slang%3D%22en-US%22%3ERe%3A%20Does%20AnyOne%20Know%20how%20to%20Debug%20SharePointPnP.PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52723%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F2387%22%20target%3D%22_blank%22%3E%40Pieter%20Veenstra%3C%2FA%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20was%20running%20the%20PowerShell%20from%20a%20PowerShell%20Window%20on%20the%20same%20VM%20as%20VS2017%20is%20running.%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20get%20the%20PowerShell%20Interactive%20Window%20displayingin%20VS2017%2C%20but%20no%20joy.%20(Cntrl%26nbsp%3B%20%2B%20SHIFT%20%2B%20%5C).%3C%2FP%3E%3CP%3EThe%20SharePointPnP.PowerShell.Commands%20Project%20is%20running%20in%20debug%20mode.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENigel%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-52703%22%20slang%3D%22en-US%22%3ERe%3A%20Does%20AnyOne%20Know%20how%20to%20Debug%20SharePointPnP.PowerShell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-52703%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F4102%22%20target%3D%22_blank%22%3E%40Nigel%20Price%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHow%20are%20you%20running%20your%20PowerShell%20commands%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20find%20deugging%20the%20easiest%20by%20running%20PowerShell%20in%20Visual%20Studio's%20PowerShell%20Interactive%20Window.%20Then%20simply%20connect%20your%20debugger%20to%3A%20PowerShellToolsProcessHost.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThen%20as%20long%20as%20your%20running%20code%20and%20source%20code%20match%20the%20debugger%20will%20pick%20up%20the%20breakpoints.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Regular 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