Monday, January 12, 2009

In an earlier post we mentioned that it is relatively easy to get the current Blueprints bits running on the Visual Studio 2010 CTP by modifying the .MSI in Orcas. At that time we forgot to mention that we need a few extra steps to really get things going with Blueprints in Visual Studio 2010.

When trying to build a Blueprint solution in Visual Studio 2010 we will notice the following error in the error window.

Error

As we can see, the build task ‘BASM’ is failing to retrieve the correct path. This task is implemented in the ‘Microsoft.SoftwareFactories.Blueprints.Builds.Tasks.dll’ that can be found in ‘..\Program Files\MSBuild\Microsoft\Blueprints\2.0’. It turns out that the execute method of this tasks looks for a (hardcoded) ‘String Value’ called ‘Blueprints’ under the ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\MSBuild\SafeImports’ tree. Because we replaced all ‘9.0’ in ‘10.0’ in the Blueprints .MSI to get it to install on Visual Studio 2010 this value doesn’t exist under ‘9.0’ anymore (but does under ‘10.0’).

To fix this we can either make sure to skip this particular replacement when modifying the .MSI in Orcas or manually add the Blueprints ‘String Value’ under the ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\MSBuild\SafeImports’ and give it the value ‘C:\Program Files\MSBuild\Microsoft\Blueprints\2.0\Microsoft.SoftwareFactories.Blueprints.targets’.

Another issue occurs when debugging our Blueprint in Visual Studio 2010. Currently, there is no property page implemented for the Blueprint project type (.bpproj) and therefore starting up Visual Studio 2008 is hardcoded in the Blueprints core. To get around this we can add an empty C# ‘Class Library’ project to our solution, set this project as the ‘StartUp’ project and make this project startup Visual Studio 2010 (property page) when debugging. Although this solution does work it makes the Visual Studio instances in my Virtual PC image VERY slow (don’t know why). Another option, that does work for me, is to leave the Blueprint project as the ‘StartUp’ project, let it start up a Visual Studio 2008 instance, (and simple ignore it) manually start another Visual Studio 2010 instance and attach this instance to the debugging process of the Visual Studio instance we started the debug session in.

Now everything is in place to *really* start developing Blueprints for Visual Studio 2010 CTP!

posted on 1/12/2009 2:07:57 PM UTC  #    Comments [0]
 Wednesday, January 07, 2009

In a previous post we already mentioned Blueprints as a means for integrating architectural guidance from the p&p App Arch Guide in the VS2010 IDE. Clemens already mentioned how we can capture some of this knowledge in an item template and use the IWizard interface to populate the diagram. Now, let’s see how we can use Item Templates in a slightly different way and use them in a Blueprint to unfold a predefined architecture (Layering Diagram) in VS2010.

The first step is to capture the architectural guidance in a Layering Diagram that we can reuse. To do this we can we create a new Modeling project and add a Layering Diagram to this project.

AddTemplate

In this diagram we can model all layers, dependencies, etc. to make it reflect our architectural guidance. Once we are done it might look something like this.

Predefined

To make this diagram reusable we have to create an Item Template for it. Unfortunately VS2010 doesn’t let us select the layering diagram in the Export Template Wizard so we have to manually create an item template for our layering diagram. The easiest way to do this is to create an Item Template for another file type (i.e. C# class) and modify the ‘MyTemplate.vstempate’ file in the .zip file that VS2010 generates and add the two diagram files (.layer and .layer.diagram) to the .zip file. The modified MyTemplate.vstemplate file should look something like this.

VSTemplate

Now we are done creating a reusable layering diagram we can integrate this with a Blueprint. (of course we can create more item templates for other architectures defined in the p&p App Arch Guide)

In this post we will not explain how to create a Blueprint from scratch but this is pretty easy. Especially after watching the How To videos. Once we have created our Blueprint we can use a Workflow Foundation based workflow to actually add our predefined layering diagram to our solution.

To do this, we first have to add a Workflow Command to our Blueprint (screen cast for more details) that will enable our Blueprint users add a layering diagram to their solution. The documentation that comes with the Blueprint Workflow Command provide us with the code we need to execute a workflow. However, this code assumes we are executing a ‘XOML only’ workflow. In our case we choose to use a codebehind for our workflow so therefor we use the ‘ExecuteWorkFlow’ method instead of the ‘ExecuteXomlWorkflow’ method. The code in your command might look like this (added some hardcoded paths instead of calls to helper class to get the correct paths).

Code

Now that we have the command in place we have to create the actual workflow that we execute from the command. After installing Blueprints we get a few extra activities that we can use in the workflows in our Blueprint. Below we can see how this workflow might look like.

Workflow

The ‘ShowDialog’ activity in this workflow is a normal ‘Code’ activity that in this case shows the (very simple) dialog that is displayed below. This dialog lets the user select the architecture that will be used in his solution.

Dialog

Once the architecture is selected, the workflow continues with the ‘CheckProjectExists’ activity. This Blueprint specific activity checks if the current solution contains a ‘Modeling project’ with the name ‘Architecture’ (I am sure you can come up with a better name ;)). If not, the project is created. After that the ‘AddLayeringTemplate’ activity is executed to actually unfold the selected item template that will add the predefined layering diagram to our modeling project in our solution.

In this post we deliberately left out some implementation details that you might need to implement this yourself. However, hopefully it does explain the basic scenario of how to add some architectural guidance from p&p App Arch Guide by using Blueprints and VS2010 Layering diagrams. In future posts we will ellaborate on this scenario, share some more technical details and eventually might even end up with a working solution that we can share :-).

posted on 1/7/2009 1:20:17 PM UTC  #    Comments [0]