Debugging NBusiness

Topics: Developer Forum
Coordinator
Oct 10, 2007 at 7:59 PM
Ok you need to do a few things to setup:

  1. Download the february 2007 Visual Studio SDK (v4), http://www.microsoft.com/downloads/details.aspx?familyid=51a5c65b-c020-4e08-8ac0-3eb9c06996f4
  2. Get the latest version of the code from this project.

Once you have done this open the solution file found in the branch you wish to work on called NBusiness.VisualStudio.sln. Set the startup project as NBusiness.VisualStudio. This project has everything related to creating the visual studio plugin and such. You may find it easier to uninstall NBusiness using add/remove programs at this point, if you have it installed. This is not exactly necessary but it just adds some confusion sometimes. When you build NBusiness.VisualStudio it does a couple things you should be aware of, though don't worry about memorizing all of this it won't be necessary to know most of this but it is helpful to get the gist just in case.

  • NBusiness.MSBuild.dll is built and copied to C:\Program Files\MSBuild\NBusiness\... along with some other assemblies
  • NBusiness.targets is copied to this folder as well. Your entity projects will use this target file to build your entity projects. Everytime you build this project it will replace this file, which is why it's helpful to uninstall NBusiness before hand. This targets file will now point to your debug assemblies.
  • Zip files with entity project templates are copied to 'C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\ProjectTemplatesExp\' and ItemTemplatesExp.
  • Registry settings will be added under the key: HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0ExpNote: The 'Exp' at the end

The last two items here are done with special MSBuild tasks in the NBusiness.VisualStudio.csproj file. So what this translates into roughly is that after building all of the projects you need to make one command line call to get everything setup in visual studio (you'll want to open the visual studio command prompt found in the visual studio start menu folder):

devenv /rootSuffix Exp /setup

You will only need to do this once unless you are working on aspects of the visual studio plugin that require refreshing it in visual studio. Working on NBusiness codegeneration templates for example will not require calling this multiple times. This will set things up in visual studio so you can run NBusiness in "experimental mode". Now you just have to either press the "start debugging" button in visual studio (starting the NBusiness.VisualStudio project will cause a new instance of VisualStudio running in experimental mode to pop up) or in case it complains about not being able to start up a class library (which is some sort of bug I'm not sure how to fix this and it seems sporadic) you can startup a new instance of visual studio manually in experimental mode with this command:

devenv /rootSuffix Exp

There is a shortcut for this in the visual studio sdk folder in the start menu I believe. Now simply attach the instance of visual studio with NBusiness loaded to the process of the new instance and you're ready to go.

To begin debugging something specific you can now go to File->New->Project and create a new entity project. Running this project will allow you to debug the NBusiness visual studio plugin. Building this project will allow you to debug NBusiness itself. To rebuild NBusiness you will need to close the experimental mode of Visual Studio, make your changes, build then start it up again.

So here's a quick recap of what you need to do:
  1. download the sdk
  2. get the latest version of the code
  3. open NBusiness.VisualStudio.sln in the branch you will be working on
  4. build the solution
  5. run devenv /rootSuffix Exp /setup via command prompt
  6. start debugging
    1. or run devenv /rootSuffix Exp via command prompt
    2. attach to the new instance

Good luck!