Skip to content

Commit e3d7afe

Browse files
Refresh SDK-based dev guide for debugging Azure PowerShell (#22717)
* Refresh SDK-based dev guide for debugging Azure PowerShell * Update documentation/development-docs/azure-powershell-developer-guide.md --------- Co-authored-by: Beisi Zhou <[email protected]>
1 parent 4c6a88f commit e3d7afe

File tree

1 file changed

+11
-14
lines changed

1 file changed

+11
-14
lines changed

documentation/development-docs/azure-powershell-developer-guide.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,19 @@ There are a few existing projects that need to be added before developing any cm
214214
Please check out the [_Cmdlet Best Practices_](./design-guidelines/cmdlet-best-practices.md) document for more information on how to create cmdlets that follow the PowerShell guidelines.
215215

216216
## Enable Running PowerShell when Debugging
217-
217+
To import modules automatically when debug has started, follow the below steps:
218+
### Set a StartUp Project
218219
- Choose any project and set it as the startup project in Visual Studio
219220
- Right click on your project in the **Solution Explorer** and select **Set as StartUp project**
220-
- Right-click on the project and select **Properties**
221-
- Go to the **Debug** tab
222-
- Under **Start Action**, pick _Start external program_ and type the PowerShell 6.0 directory
223-
- For example, `C:\Program Files\PowerShell\6\pwsh.exe`
224-
225-
### Importing Modules
226-
227-
To import modules automatically when debug has started, follow the below steps:
228-
229-
- In the **Debug** tab mentioned previously, go to **Start Options**
230-
- Import the Profile module, along with the module you are testing, by pasting the following in the **Command line arguments** box (_note_: you have to update the <PATH_TO_REPO> and <SERVICE> values provided below):
231-
- `-NoExit -Command "Import-Module <PATH_TO_REPO>/artifacts/Debug/Az.Accounts/Az.Accounts.psd1;Import-Module <PATH_TO_REPO>/artifacts/Debug/Az.<SERVICE>/Az.<SERVICE>.psd1;$DebugPreference='Continue'"`
232-
- **Note**: if you do not see all of the changes you made to the cmdlets when importing your module in a PowerShell session (_e.g.,_ a cmdlet you added is not recognized as a cmdlet), you may need to delete any existing Azure PowerShell modules that you have on your machine (installed through the PowerShell Gallery) before you import your module.
221+
### Setup a Debug Profile
222+
- Please refer to [Debug Page, Project Designer](https://learn.microsoft.com/visualstudio/ide/reference/debug-page-project-designer?view=vs-2022) for how to access the Debug page
223+
- Create a **Excutable** new Debug profile
224+
- For Azure PowerShell, please setup debug profile in the following way
225+
- Set **Excutable** to the path of the excutable file of PowerShell core, for example,`C:\Program Files\PowerShell\7\pwsh.exe`
226+
- Import the Profile module, along with the module you are testing, by pasting the following in the **Command line arguments** box (_note_: you have to update the <PATH_TO_REPO> and <SERVICE> values provided below):
227+
- `-NoExit -Command "Import-Module <PATH_TO_REPO>/artifacts/Debug/Az.Accounts/Az.Accounts.psd1;Import-Module <PATH_TO_REPO>/artifacts/Debug/Az.<SERVICE>/Az.<SERVICE>.psd1;$DebugPreference='Continue'"`
228+
229+
**Note**: if you do not see all of the changes you made to the cmdlets when importing your module in a PowerShell session (_e.g.,_ a cmdlet you added is not recognized as a cmdlet), you may need to delete any existing Azure PowerShell modules that you have on your machine (installed through the PowerShell Gallery) before you import your module.
233230

234231
## Adding Help Content
235232

0 commit comments

Comments
 (0)