How can one run a non-standard MSBuild target from within a flavored project? RRS feed

  • Question

  • I'm implementing a flavored project and I'm trying to add a new "build" option, that will perform post-build deployment steps. There are a couple issue requirements that make this a little more complex than just adding a after-build step to my project template.

    One issue is that I want to present UI that captures a few options about where to deploy the assemblies, but I don't want these properties to be in the csproj file because of our development model, developers will be deploying to different dev stores, but they will be sharing the same csproj file in source control. So, I figured I could pass the required parameters as "global" parameters to MSBuild. All of this works perfectly from the msbuild command-line, but I'm having problems figuring out how to perform this operation within my visual studio extension.

    I first came across the EnvDTE.SolutionBuild class which looked promising. The problem is that it only seems to be aware of the "standard" build targets: "Build", "Clean", "Run", etc. But I don't see any way to use this class to invoke a custom target, or even pass global properties to the build.

    The other option is to use the MSBuild framework classes directly within my extension. The Microsoft.Build.Execution.ProjectInstance class exposes everything I need to invoke the build task. I can create a custom Microsoft.Build.Framework.ILogger to output to the Build output pane. I've got this working more or less. The problem is that Visual Studio has no idea what is going on because I'm doing things on the side. So, for example, there will be no "building" icon or progress bar shown in the status bar, and the other Build menu options will remain available, because VS doesn't know that a build is already happening.

    So, I'm looking for advice on the best way to accomplish this. Is using MSBuild classes directly, not the right approach? Is there some other interface I need to use to notify the shell what I'm doing?



    Friday, March 8, 2013 9:15 PM