Title: Building you build process with Windows Workflow Foundation
1Building you build process with Windows Workflow
Foundation
2Agenda
- Existing build technologies
- Promise of Workflow Foundation
- Demonstration reusing Nant scripts
- Demonstration - Custom Task
- Authoring Modes
- Serialization and Deserialization
- Designer Re-Hosting
3Existing build technologies
- Cruise Control
- MS Build
- Nant/Ant
- Visual Build
- Automated Build Studio
- DB Change management tools (DB Ghost,
Embarcadero) - Make files, batch files, any other
4Motivation for new way of building software
Existing build technologies
- Objectives
- Visual Configuration (script free)
- Real-time distributed feedback
- Parallel Task processing
- Cheap
5Possibilities that WF provides
Promise of Windows Workflow Foundation
- Design by markup
- Access to high level programming language
- Threading, tracing, events
- End user configuration
6The Four Workflow Tenants
Promise of Windows Workflow Foundation
- Co-ordinate work performed by people and software
- Long-running and stateful
- Based on extensible models
- Transparent and dynamic throughout their life
cycle
7Motive for a Dynamic Build process
Promise of Windows Workflow Foundation
- Build technologies
- New software development technologies and
platforms - Configuration
8Scenario
Promise of Windows Workflow Foundation
Start
Checkout
ConfigMode Release?
Compile in Release configuration
Compile in Debug configuration
Deploy
Stop
9Build script encapsulation demo
Promise of Windows Workflow Foundation
- Reuse of existing scripts and build technologies
- Example of a code only workflow
10Authoring Modes
Promise of Windows Workflow Foundation
Full Visual Studio Support
- Code Only
- Markup (XAML) Compiled Code Beside
Some Visual Studio Support Prayer
11Custom Activities
Workflow Customization
- Part of Workflow tenants (Based on extensible
models) - Reusable components
- Possibility of Software Build DSL
12Domain Specific Language
Workflow Customization
- Limited form of computer language designed for a
specific class of problems. - Library(Framework) Configuration (Process,
algorithm or how to perform a process) - Most Frameworks in a particular platform address
technical concerns - DSLs address business concerns (Higher level
level of abstraction)
13Domain Specific Language
Workflow Customization
- DSLs typically come with a code generation tool
- Constraint syntax
- Accessible to non-developers
14Domain Specific Language
Workflow Customization
- May require a Parser
- Schemas help to validate instructions
- Algorithm Syntax - what is being said is
limited
15Domain Specific Language
Workflow Customization
- Algorithm Syntax - what is being said is
limited - How it is being said may take two forms
- Internal DSL - syntax of instruction is a subset
of host general purpose language code - External DSL often a configuration file
16Custom Workflow
Workflow Customization
DependencyObject ltabstractgt
Activity
MyCustomActivity
CompositeActivity
SequenceActivity
SequentialWorkflowActivity
MyCustomWorkflow
System.Workflow.ComponentModel
17Activity Class
Workflow Customization
DependencyObject ltabstractgt
- Methods to override
- Execute
- Cancel
- Initialize
- These are called by the WF runtime not manually
Activity
Execute(ActivityExecutionContext)ActivityExecuti
onContext Cancel(ActivityExecutionContext)Activi
tyExecutionContext Initialize(IServiceProvider)
18Activity Class State
Workflow State
Initialized
Executing
Closed
Faulting
Canceling
Compensating
19Dependency Object Dependency Properties
Workflow State
DependencyObject ltabstractgt
- Activity data storage mechanism
- Allows activities to project their properties
onto their children - Essential provision for WF tenent (Long-running
and stateful)
20Dependency Object
Workflow State
- Hash table
- Essential provision for WF tenant (Long-running
and stateful) - Add a public static instance of Dependency
Property to manage that property for all
instances of the activity - Implement .NET Property that accesses an
activities Dependency Property
21Dependency Properties
Workflow State
- Must derive from DependencyObject
- Register property then define property
22Dependency Properties
Workflow State
public static DependencyProperty
MyDepPropProperty DependencyProperty.Register(
MyDepProp", typeof(String),
typeof(MyClass) )
Property name
Property Type
Owner Type
23Dependency Properties
Workflow State
public String CompilationMode get
return (String)(base.GetValue(MyClass.
MyDepPropProperty)) set
base.SetValue(MyClass.MyDepPropProperty, value)
24Parameter Passing
Workflow State
DictionaryltString, Objectgt Args new
Dictionaryltstring, objectgt() Args.Add("Repositor
ySource", "C\\Projects\\BuildManager\\Repository"
) Args.Add("CompilationMode", "Release")
Args.Add("Application", "C\\Projects\\BuildManage
r\\Checkout\\BuildMeWinApp\\BuildMeWinApp.sln") A
rgs.Add("Target", "C\\Projects\\BuildManager\\Bui
ldTarget") WorkflowInstance instance
workflowRuntime.CreateWorkflow(typeof(BuildTasks.B
uilder), Args)
25Build custom workflow demo
Custom Workflow
- Domain specific activities
- Domain specific workflow
- Example of CodeMarkup workflow
26Markup
Authoring Modes
ltSequentialWorkflowActivity xClass"MarkupBuild.B
uild" xName"Build" xmlnsns0"clr-namespaceBu
ildTasksAssemblyBuildTasks, Version1.0.0.0,
Cultureneutral, PublicKeyTokennull"
xmlnsx"http//schemas.microsoft.com/winfx/2006
/xaml" xmlns"http//schemas.microsoft.com/winfx/2
006/xaml/workflow"gt ltns0Checkout
BuildFile"xNull" xName"checkout1"
RepositorySource"xNull" /gt ltns0Compile
BuildFile"xNull" xName"compile1"
CompilationMode"xNull" Application"xNull
" /gt ltns0Deploy BuildFile"xNull"
xName"deploy1" CompilationMode"xNull"
Target"xNull" /gt lt/SequentialWorkflowActivitygt
27XOML
Authoring Modes
- Extensible Orchestration Markup Language (XOML)
files, a special case of XAML file types, which
specify the workflow logic within an application.
28Binding
Authoring Modes
ltSequentialWorkflowActivity xClass"MarkupBuild.B
uild" xName"Build" xmlnsns0"clr-namespaceBu
ildTasksAssemblyBuildTasks, Version1.0.0.0,
Cultureneutral, PublicKeyTokennull"
xmlnsx"http//schemas.microsoft.com/winfx/2006
/xaml" xmlns"http//schemas.microsoft.com/winfx/2
006/xaml/workflow"gt ltns0Checkout
xName"checkout1" RepositorySource"ActivityBind
Build,PathRepositorySource" /gt ltns0Compile
xName"compile1" CompilationMode"ActivityBind
Build,PathCompilationMode" Application"Activit
yBind Build,PathApplication" /gt ltns0Deploy
xName"deploy1" Target"ActivityBind
Build,PathTarget" CompilationMode"ActivityBind
Build,PathCompilationMode" /gt lt/SequentialWorkf
lowActivitygt
29Binding
Authoring Modes
- gives a dependency property an ActivityBind
object to evaluate when asked for its value - ActivityBind can point to other fields,
properties, or methods of activities inside a
workflow. - One activity could bind its input properties to a
previous activity's outputs. - Binding makes the data flow a part of the
workflow model.
30Markup-only workflows
Authoring Modes
- Allows for declarative programming
- Facilitates the highest degree of encapsulation
- Facilitates usage of code-generation tool
- Requires mechanism to serialize and deserialize
WF
31Serialization
Serialization
- Serialization
- Create a XAML workflow markup file from an
in-memory workflow model - Deserialization
- Reads markup and creates in-memory object
containing definition of workflow model
32Serialization
Serialization
private static void SerializeToMarkup(Activity
workflow, String fileName) try
using (XmlWriter xmlWriter
XmlWriter.Create(fileName))
WorkflowMarkupSerializer mrkupSerializer new
WorkflowMarkupSerializer()
mrkupSerializer.Serialize(xmlWriter, workflow)
catch (Exception e)
Console.WriteLine("Exception during
serialization 0" e.Message)
33Deserialization
Serialization
- Deserializer needs knowledge of the types
referenced in the markup - ServiceContainer, TypeProvider,
DesignSerializationManager
34 Serialization
Activity workflow null ServiceContainer
container new ServiceContainer() Add a
TypeProvider to resolve BuildTask
references TypeProvider provider new
TypeProvider(container) provider.AddAssembly(type
of(SharedWorkflows.MarkupOnlyBaseWorkflow).Assembl
y) container.AddService(typeof(ITypeProvider),
provider) Add ServiceContainer with the
TypeProvider to serialization manager DesignerSer
ializationManager dsm new DesignerSerializationM
anager(container) XmlReader xmlReader
XmlReader.Create(fileName) WorkflowMarkupSerialize
r markupSerializer new WorkflowMarkupSerializer(
) workflow markupSerializer.Deserialize(dsm,
xmlReader) as Activity
35Designer Re-Hosting
- Code generation tool
- Configurable by end user
36Introduction
Designer Re-hosting
- The logic of a build process is often simple
enough for to allow drag and drop process design
by non-developers - WF allows for re-hosting the workflow designer in
a windows application (outside of the Visual
Studio environment) - Powerful proposition
37 Designer Classes
- System.ComponentModel.Design.DesignSurface
- General-purpose design canvas
- System.Workflow.ComponentModel.Design.
- WorkflowDesignerLoader
- Serialization/Deserialization
- Loading of services used by the designer
- System.Workflow.ComponentModel.Design.WorkflowView
- Implements visual representation of your workflow
model
38 Designer Classes
Design Surface
Load services and populate visual tree
IRootDesigner
GetServices method
GetDesigner method
MyDesignerLoader WorkflowDesignerLoader
BeginLoad method
IDesignerHost
Persisted Workflow Models (.xoml files)
GetView method
WorkflowView
39Property Attributes
Designer Re-hosting
- Description
- Category
- Browsable
- DesignerSerializationVisibility
40WorkflowDesignerLoader
Designer Re-hosting
- Abstract
- Must be implemented in a derived class
- Responsible for loading workflow from peristable
tore .xoml and populating tree of visual objects
in the designer and Vise-Versa
41 Designer Re-hosting
- Services
- IMenuCommandService
- ITypeProvider
- IToolboxService
- IPropertyValueUIService
- IEventBindingService
42 Designer Re-hosting
- Demo
- Simple workflow
- Workflow with conditional branch
43 Conclusion
- Revisiting Objectives
- Visual Configuration (script free)
- Real-time distributed feedback
- Parallel Task processing
- Cheap
44 Conclusion
- Real-time distributed feedback
- Limitation is due to fact that WF Markup is a
subset of XAML the markup parser is not
extensible - Parallel Task processing
- Parallel task activity is not multithreaded
- This can be implemented but its not out-of-the
box functionality
45 Conclusion
- References
- Pro WF Windows Workflow in .NET 3.0, Apress,
Bruce Bukovics - Professional Windows Workflow Foundation, Wrox,
Todd Kitta - Introduction to Domain Specific Languages, Martin
Fowler, http//www.infoq.com/presentations/domain-
specific-languages
46Blank Slide
Serialization