In Visual studio 2010 Team Architect edition, you have a new type of diagram available, called the layer diagram. What is great about this diagram is that you can use it to actually validate if the source code you have written adheres to the rules you defined in terms of allowed dependencies between layers. This adds great value to the notion of modeling the layers for your product and can help you mandate the rules you pose as an architect are actually followed by the development team.
In the visual studio IDE you can run a layer validation just by right clicking the diagram and selecting the option Validate, as show in screenshot below:
But what If I want to run this validation every time you compile the project, or even better during each build we run on the build server?
Cameron Skinner has a blog post based on the PDC CTP bits, on how you can create the layer diagram and link it into your solution for validation. The Beta 1 we currently use has the option to Validate default available in the dropdown of available actions for the linked diagram. But unfortunately it does not validate straight out of the box.
It took me quite some digging around in the target files that come with the architect edition, but I discovered that there is a property called ValidateArchitectureOnBuild that enables or disables the layer validation during the build.
So in order to enable the build during build, you must add this property to your build file. This can be done by unloading the project and adding the property to the property group that contains several options you select in the properties page of your project.
Once you reload the the project and run a local compile you will see the layer diagram is validated during the compilation pass.
Hope this helps you get layer validation running as an integral part of your build process 🙂
CTO at Xpirit, Microsoft Regional Director, Visual studio ALM MVP, Speaker, Pluralsight Author and IT Architect Consultant