When developing custom STSADM commands, it could be handy to debug our code in the real execution context of STSADM. To do so, you only have to deal with your Visual Studio project configuration.
1. Right click your VS project and go to properties
2. From Build Events tab, paste the following commands into the Post-buid event command line box
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /uf $(TargetName)
"%programfiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe" /if "$(TargetPath)"
3. From Debug tab, choose Start external program as a Start Action and browse for file C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\BIN\STSADM.EXE
4. In the Command line arguments text box, specify -o <name of your command> and the rest of your input parameters
5. You can now add break points to your code, run your project and debug your code in real conditions