简体   繁体   中英

Publish a web app from within an VS2010 Extension

I want to publish a web app from within an VS2010 extension. In macro I use to write:

DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()
DTE.ActiveWindow.Object.GetItem("MyWebApp").Select(vsUISelectionType.vsUISelectionTypeSelect)
DTE.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Publish")

but this doesn't seem to work from within an extension (c#).

It fails on the second line in c#, in VBA macro this works fine...

What is the correct way to start publishing process from a VS2010 extension?

Seems I need to put the solution name in front of the Web application name, so this code works:

        var dte = _package.GetServiceOf(typeof(DTE)) as DTE;

        string solutionName = Path.GetFileNameWithoutExtension(dte.Solution.FullName);

        dte.Windows.Item(vsWindowKindSolutionExplorer).Activate();
        dte.ActiveWindow.Object.GetItem(solutionName + "\\" + webProjectName).Select(vsUISelectionType.vsUISelectionTypeSelect);
        dte.ExecuteCommand("ClassViewContextMenus.ClassViewProject.Publish");

Thanks to a hint from Chao Kuo on my post http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/2825d129-2f48-44f6-acf8-4038c9fd276d/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM