开发者

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 l开发者_如何学Goine 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/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜