VSX: Custom Package's Project Type to mimik "Debug >> Start Action >> Start External Program"

932 views Asked by At

I have a custom project type based on the C# Class Library project type in a VSX Package (2008+). For this project type, even though the output is a class library, I want to be able to debug this app just by pressing F5 (etc). I have a prebuilt executable that takes an assembly path as a command-line argument and loads it for workbench testing.

I can simulate this behavior manually by using the Project's "Debug >> Start Action >> Start External Program" in the property pages by providing the path to the executable and providing the relative path to the output dll as a command line argument. But this is too much setup. I would want the project type's package code to be able to grab the assembly of the active configuration and the installed location of the workbench executable automatically.

The worst case scenario would be that after every successful build, the property pages for that project are updated programmatically with the correct values. I don't particularly like this solution because it seems messy, seems like it would be easy to get out of sync and expose those potential errors to the user.

The best solution that I can imagine involved intercepting the Start Debugger event (only for this project type) before it craps out with "A project with an Output Type of Class Library cannot be started directly" and executes the workbench instead (debugger attached, of course). I don't know if VSX exposes the necessary parts.

I would pay to have this simple (?) package (along with a few other requirements, mainly a project-level menu item, already partially implemented) written by someone with experience, but I haven't found any consultants that specialize in VSX packages. Recommendations are welcome.

Am I taking the wrong approach? I'm assuming I need a package rather than an add-in.

1

There are 1 answers

6
Aaron Marten On BEST ANSWER

Based on your description, it sounds like you don't have a custom project type, but rather a custom project template. (You would typically only have your own project type if you had your own custom programming language).

Assuming this is the case, I think you should be able to create your own IWizard implementation which would set the project up for launching your host executable, etc... at project creation time (i.e. after the user goes through the New Project dialog).

For example, you could do something like the following in the IWizard's ProjectFinishedGenerating implementation:

public void ProjectFinishedGenerating(Project project)
{
  foreach (Configuration config in project.ConfigurationManager)
  {
    config.Properties.Item("StartAction").Value = 1; //Launch external program
    config.Properties.Item("StartProgram").Value = <pathToYourEXE>;
    config.Properties.Item("StartArguments").Value = <argumentsToYourExe>;
  }
}