Thursday, March 10, 2011

Blogging in the Key of Nerd: Setting Up a Debug Environment in the Dynamics GP Client With Locally Built Code Consumed from the Dex Depot

I had an interesting time trying to set up a debug environment with the Business Analyzer code the other day. This code is stored in the Dexterity depot and consumed as part of the GP build. Due to the difference in the test keys between the two branches, it is not possible to just build locally and drop debug assemblies over the top of the installed components.

Instead, there are a few steps you have to perform. First, go to your project file's debug tab in Visual Studio and set up some debugging options. This involves launching your debug session by starting an external program, in this case Dynamics.exe. Don't forget to use the .set file.

(click to enlarge)

Next you need to go to the Signing tab and set the build process to build with the correct test key. For our project this is located in the \keys folder.

(click to enlarge)

Once this is done, go to the following location in the source codes' depot (in my case this is the Dex11.0 depot): \private\developer. Create a folder in this location with your alias as its name. Create a subfolder called "build". Inside of this build folder create a file called "userenv.cmd". The contents of this file should look like this:

@echo off
rem ******
rem Set type of signing

rem test -- use the test key and full signing
rem delay -- use the real key and do delay signing
rem none -- don't do signing at all
rem prs -- official delay signing
rem ******

set MY_SIGNING=delay
set PREFIX_HOME=%INETROOT%\build\tools\prefix\5.6
set PATH=%PATH%;%INETROOT%\public\ext\fxcop\1.35\x86;%INETROOT%\build\tools;%PREFIX_HOME%\bin;%_NTDEVELOPER%
if exist "%BC_PATH%" (
set SDDIFF=%BC_PATH%

set SDUDIFF=%BC_PATH%
)
if exist "%INETROOT%\build\allpreenv.cmd" (
call "%INETROOT%\build\allpreenv.cmd" %MY_SIGNING%
)
if /i "%MY_SIGNING%"=="none" (
set MY_SIGNING=no
)

for %%i in ("%INETROOT%") do title %%~ni%%~xi %MY_SIGNING% signing

set MY_SIGNING=

Then, close your enlistment command prompt and relaunch. Build your assemblies (debug, of course), drop them into their locations in the GP client install on your machine, and start debugging.

If you run into issues, you may need to disable strong name verification for your debug assemblies. You can do this from your enlistment with the following command:

sn -Vr [assembly]

If you're doing this from the depot, you aren't likely to be in the location where your assembly lives in the GP client install. Remember to provide the full path of each assembly to the sn tool.

No comments:

Post a Comment