Language: VB.NET
Visual Studio macro to toggle the MvcBuildViews value
Sub ToggleMvcBuildViews() DTE.ExecuteCommand("Project.UnloadProject") DTE.ExecuteCommand("OtherContextMenus.StubProject.EditProjectFile") Dim wasSetToTrue As Boolean = SetMvcBuildView(True) Dim wasSetToFalse As Boolean If Not wasSetToTrue Then wasSetToFalse = SetMvcBuildView(False) End If If (wasSetToTrue Or wasSetToFalse) Then DTE.ActiveDocument.Save() End If DTE.ActiveDocument.Close() DTE.ExecuteCommand("Project.ReloadProject") Dim msgBoxTitle As String = "Toggle MvcBuildViews" If wasSetToTrue Then MsgBox("MvcBuildViews property was set to True", Title:=msgBoxTitle) ElseIf wasSetToFalse Then MsgBox("MvcBuildViews property was set to False", Title:=msgBoxTitle) Else MsgBox("Unexpected Error: Unable to toggle MvcBuildViews property", Title:=msgBoxTitle) End If End Sub Function SetMvcBuildView(ByVal value As Boolean) As Boolean DTE.ExecuteCommand("Edit.Replace") Dim findResult As vsFindResult findResult = DTE.Find.FindReplace(vsFindAction.vsFindActionReplaceAll, _ FindWhat:="<MvcBuildViews>" & IIf(value, "false", "true").ToString() & "</MvcBuildViews>", _ vsFindOptionsValue:=(vsFindOptions.vsFindOptionsFromStart Or vsFindOptions.vsFindOptionsMatchCase), _ ReplaceWith:="<MvcBuildViews>" & IIf(value, "true", "false").ToString() & "</MvcBuildViews>", _ Target:=vsFindTarget.vsFindTargetCurrentDocument, _ ResultsLocation:=vsFindResultsLocation.vsFindResultsNone) SetMvcBuildView = True If (findResult = vsFindResult.vsFindResultNotFound) Then SetMvcBuildView = False End If ' close find/replace dialog DTE.Windows.Item("{CF2DDC32-8CAD-11D2-9302-005345000000}").Close() End Function
Tags:
Description:
for more details http://algonzalez.tumblr.com/post/263944271/macro-to-toggle-mvcbuildviews-property
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

