I'm trying to write a visual studio extension that allows me to publish multiple web applications in a solution, similar to using the one-click publish feature on all the projects.
DTE2 service = (DTE2)this.GetService(typeof(DTE));
Projects projects = service.Solution.Projects;
SolutionBuild2 build = (SolutionBuild2)service.Solution.SolutionBuild;
foreach (Project project in projects)
{
build.PublishProject("Release", project.UniqueName, true);
}
When I try to run this code, the only result in the output window is this:
Error: Object reference not set to an instance of an object.
========== Publish: 0 succeeded, 0 failed, 0 skipped ==========
... which doesn't tell me much. Is there a way to find out what's going wrong?
I also see there an interface IVsPublishableProjectCfg, but there doesn't seem to be any examples of how to use it.
Is there another way to programmatically publish web applications to a certain directory, similar to how the one-click publish feature works?