Share via


Navigate in a Complex Windows Workflow

Various tasks in Visual Studio Ultimate require that you modify Windows Workflow files, some of which have complex structures and deeply nested elements. For example, the following kinds of files can be difficult to navigate and modify:

  • Custom templates for Team Foundation Build that are based on its Default Template (DefaultTemplate.xaml).

  • Custom templates for Visual Studio Lab Management that are based on its Default Template (LabDefaultTemplate.xaml).

Some topics that explain how to work with such files describe the location of a specific element in a Windows Workflow file in shorthand syntax. This topic explains how to use this syntax to find a specific element that you want to work with.

In this topic

  • Example: "Run MSBuild for Project"

  • Find a workflow element by using the Workflow Designer

  • Find a workflow element by using the XML Editor

Example: "Run MSBuild for Project"

For example, you might create a custom build process by modifying a copy of DefaultTemplate.xaml to change how the build process uses MSBuild to compile your code. To make this change, you must modify a property of the Run MSBuild for Project element.

Before you can modify that element, you must first navigate through 14 container elements to locate it in the structure of the workflow. For example, the topic that covers this task exposes the structure in the following way:

  1. Sequence (Sequence) >

  2. Run On Agent (AgentScope) >

  3. Try Compile, Test, and Associate Changesets and Work Items (TryCatch [Try]) >

  4. Sequence (Sequence) >

  5. Compile, Test, and Associate Changesets and Work Items (Parallel) >

  6. Try Compile and Test TryCatch [Try] >

  7. Compile and Test Sequence >

  8. For Each Configuration in BuildSettings.PlatformConfigurationsForEach [Body] >

  9. Compile and Test for Configuration Sequence >

  10. If BuildSettings.HasProjectsToBuild If [Then] >

  11. For Each Project in BuildSettings.ProjectsToBuildForEach [Body] >

  12. Try to Compile the Project TryCatch [Try] >

  13. Compile the Project Sequence >

  14. Run MSBuild for Project MSBuild

This syntax shows you the nested structure that contains the element that you must locate. Each element follows the element that contains it. For example, the Run MSBuild for Project element is contained in the Compile the Project element, which is contained in the Try block of the Try to Compile the Project element.

Find a workflow element by using the Workflow Designer

You should consider the following aspects of using the Workflow Designer:

  • Advantage: You do not have to worry that you might make schema errors that break your workflow.

  • Advantage: You may be more comfortable with this approach if you prefer to work with a visual model instead of editing code.

  • Disadvantage: Some tasks might take longer with the designer than with a text-based editor.

  • Disadvantage: The Workflow Designer makes your workflow files larger than they would be if you edited them by using the XML Editor.

To open a Windows Workflow file in the Workflow Designer, open Source Control Explorer, find the folder that contains the .xaml file, and then double-click it.

To find the Run MSBuild for Project element by using the Workflow Designer, start by focusing on the top levels in the previous example:

  1. Sequence (Sequence) >

  2. Run On Agent (AgentScope) >

  3. Try Compile, Test, and Associate Changesets and Work Items (TryCatch [Try]) >

  4. Sequence (Sequence) >

  5. ...

In the Workflow Designer, make sure that you are looking at a fully collapsed view of the Process element. At the top of the Workflow Designer window, click Process, and then click Collapse All. The window now resembles the following view:

Top levels of the Default Template fully collapsed

To start to navigate to the element that you seek, perform either of the following steps in the Run on Agent element:

Two ways to navigate into a workflow element

If you double-click Double-click to view, the result resembles the following view:

Run On Agent activity in isolation

In this view, you can more easily concentrate your attention directly inside the element with which you are working. However, you lose sight of the broader context.

If you click the ExpandExpand icon instead, the result resembles the following view:

Run On Agent activity in context

In this view, you keep the broader context visible, which can sometimes be helpful. But as you navigate more deeply into the structure, the complexity and size of the view might start to overwhelm you.

Use whichever method best suits your work. Repeat the pattern by starting at the top of the list and working your way through each element until you reach the element that you seek.

Find a workflow element by using the XML Editor

You should consider the following aspects of using a text-based editor such as the XML Editor:

  • Advantage: You can complete certain tasks more quickly and efficiently. For example, you can quickly find and replace a specific piece of XAML, or you can quickly make a global change.

  • Advantage: You may prefer this approach if you are comfortable working with code.

  • Disadvantage: You risk making a schema error that breaks your workflow.

To find a workflow element by using the XML Editor

  1. In Source Control Explorer, open the folder that contains your workflow.

  2. Near the top of the window, click the link that appears next to Local Path.

    Windows Explorer appears and displays the contents of the folder.

    Note

    If the Not mapped link appears next to the Local Path label at the top of Source Control Explorer, click the link to map the server directory to the appropriate directory in your local workspace.

  3. In Windows Explorer, hold down the SHIFT key as you right-click the .xaml file that contains the workflow. Release the SHIFT key, and then click Copy as Path.

  4. In Visual Studio 2010, open the File menu, click Open, and then click File.

  5. In the Open File dialog box, leave the cursor in the File name box, and then press CTRL+V to paste the path.

  6. Click the icon next to the Open button, and then click Open With.

  7. In the Open With dialog box, click XML (Text) Editor.

    Tip

    Click Set as Default if you want to always use the XML (Text) Editor to edit .xaml files such as Windows Workflow files.

    Click OK.

    The contents of your workflow appear in the XML (Text) editor window.

  8. Use the XML (Text) editor to find (for example, by pressing Ctrl+F) the element, and then make the changes you want.

    Important

    Make sure that none of your changes violate the rules of the workflow schema. Otherwise, the workflow may fail or function incorrectly.

Additional Resources

You can find additional information in the following topics on the Microsoft website:

See Also

Concepts

Create and Work with a Custom Build Process Template

Create a Workspace to Work with your Team Project