Share via


How to: Compile Workflows

You can construct workflows in three ways:

  • By declaratively using workflow markup in a workflow markup file that has the file name extension .xoml. This workflow file can then be compiled with the workflow compiler or it can be passed into the workflow runtime engine through a host application without being compiled. This is referred to as no-code workflow authoring. For more information, see Using Workflow Markup. The file that is created has a .xoml file extension.

  • The markup file can be used to declare the workflow, but it is then compiled with a code file that contains implementation logic. This is referred to as code-separation workflow authoring. In this case, the files that are created have a .xoml and .xoml.cs or .xoml.vb file extensions.

  • By using the Windows Workflow Foundation object model in a code file. This is referred to as code-only workflow authoring. In this case, the files created have standard C# or Visual Basic source code file extensions. These files are also compiled.

Compilation Process

When workflows are compiled, the following procedures are performed as part of the compilation process:

  • Validation is performed to ensure that the workflow activities validate based on the rules that the activities have set for themselves. If there are validation errors, the compiler returns a list of the errors.

  • A partial class is generated from the markup definition that is input into the compiler.

  • Code is generated to help with the run-time execution of the activities. Event subscriptions are generated, which help activities know when the activities they contain are finished executing.

  • The partial classes generated from the markup file and the partial classes from the code file are entered into the .NET Framework C# or Visual Basic compiler. The output of this process is the .NET assembly, WorkflowSample.dll. This can be deployed to run the workflow.

Using the wfc.exe Workflow Command-line Compiler

Windows Workflow Foundation provides a command-line workflow compiler named wfc.exe. Windows Workflow Foundation also provides a set of public types that support workflow compilation for custom compiler development. These public types are the same types used internally by wfc.exe. You can create a custom version of the compiler by using the WorkflowCompiler class.

You can also use the WorkflowCompiler class to compile workflows as shown in the following simple example.

WorkflowCompiler compiler = new WorkflowCompiler();
WorkflowCompilerParameters param = new WorkflowCompilerParameters();
compiler.Compile(param, new string[] { "MainWorkflow.xoml" });

For more information, see the WorkflowCompiler class in the Windows Workflow Foundation Class Library reference.

Compiler Options

The wfc.exe workflow command-line compiler options are documented in the following code-style topic.

Microsoft (R) Windows Workflow Compiler version 3.0.0.0
Copyright (C) Microsoft Corporation 2005. All rights reserved.

                  Windows Workflow Compiler Options

wfc.exe <Xoml file list> /target:assembly [<vb/cs file list>] [/language:...] 
        [/out:...] [/reference:...] [/library:...] [/debug...] [/nocode...] 
         [/checktypes...] [/resource:<resource info>]

                        - OUTPUT FILE -
/out:<file>             Output file name
/target:assembly        Build a Windows Workflow assembly (default).
                        Short form: /t:assembly
/target:exe             Build a Windows Workflow application.
                        Short form: /t:exe
/delaysign[+|-]         Delay-sign the assembly using only the public portion
                        of the strong name key.
/keyfile:<file>         Specifies a strong name key file.
/keycontainer:<string>  Specifies a strong name key container.

                        - INPUT FILES -
<Xoml file list>        Xoml source file name(s).
<vb/cs file list>       Code-beside file name(s).
/reference:<file list>  Reference metadata from the specified assembly file(s).
                        Short form is '/r:'.
/library:<path list>    Set of directories where to lookup for the references.
                        Short form is '/lib:'.
/resource:<resinfo>     Embed the specified resource. Short form is '/res:'.
                        resinfo format is <file>[,<name>[,public|private]].

Rules and freeform layout files must be embedded as assembly resources.
The resource name is constructed by using the namespace and type name
of the activity. For example, an activity named "MyActivity" in namespace
"WFProject" would require resource names "WFProject.MyActivity.rules"
and/or "WFProject.MyActivity.layout".

                        - CODE GENERATION -
/debug[+|-]             Emit full debugging information. The default is '+'.
/nocode[+|-]            Disallow code-beside model.
                        The default is '-'. Short form is '/nc:'.
/checktypes[+|-]        Check for permitted types in wfc.exe.config file.
                        The default is '-'. Short form is '/ct:'.

                        - LANGUAGE -
/language:[cs|vb]       The language to use for the generated class.
                        The default is 'CS' (C#). Short form is '/l:'.
/rootnamespace:<string> Specifies the root Namespace for all type declarations.
                        Valid only for 'VB' (Visual Basic) language.
                        Short form is '/rns:'.

                        - MISCELLANEOUS -
/help                   Display this usage message. Short form is '/?'.
/nologo                 Suppress compiler copyright message. Short form is '/n'.

/nowarn                 Ignore compiler warnings. Short form is '/w'.

See Also

Reference

WorkflowCompiler

Concepts

Workflow Authoring Modes
Serializing Custom Activities
How to: Serialize Workflows