Incorporate Layer Validation in your Builds
As I promised in my last post, I want to show you how you can make Layer Validation part of your build process. I'm going to assume you've followed along from last post to make things easy. Again, this is all possible in the VSTS 2010 CTP.
Unload the "Client" project ( Right click on the "Client" project and select "Unload Project" )
Once unloaded, right click on the unloaded "Client" project and select "Edit Client.csproj":
Find this line:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />And add this line right after it:
<Import Project=" $(ProgramFiles)\Microsoft Visual Studio 10.0\Team Tools\Architecture Tools\Microsoft.VisualStudio.TeamArchitect.Validate.Targets"/>
This is a temporary step to make this work in the CTP. At RTM ( and even for Beta ), the new targets file will be part of the core MSBuild targets file.
Save the project, then reload.
You'll be presented with this dialog:
Click on the "Load project normally" and click OK.
Now drag the "FirstLayerDiagram.layer" file from the "Diagrams" solution folder into the "Client" project.
Delete the "FirstLayerDiagram.layer" file from the solution folder.
Select the "FirstLayerdiagram.layer" file that is now in the "Client" project, and set its "Build" action to "Validate":
Now if you did want to leave the "FirstLayerDiagram.layer" file in the "Diagrams" solution folder, you would have to manually edit the "Client.csproj" file, changing this line:<Validate Include="FirstLayerDiagram.layer" />
to this:
<Validate Include=" ..\ FirstLayerDiagram.layer" />
You're project would look something like this ( notice the little arrow overlay, indicating that this is a reference to a file elsewhere ):
Now at this point you could drop to the command line, assuming the Client.csproj file is in "c:\temp\Layer Validation\Client", and type "msbuild /t:ValidateArchitecture".
Ideally, it would be great to incorporate this step into the build process whenever you build the solution or Client project. You would do something like add a DependsOn="ValidateArchitecture" attribute to the "AfterBuild" target in the project file. Unfortunately, the same bug that requires you to refresh the Architectural Explorer after each build of the project will prevent this from working as it should. Clearly, this will be corrected by RTM.
Hope that helps!
Cameron
Comments
Anonymous
December 11, 2008
Layer Validation with the VSTS 2010 CTPAnonymous
December 20, 2008
It's nice to see how a professional explains things :)..I mean I regularly read all of your VSTS 2010 posts and try out everything you do in your posts..for me that is the easiest way to learn new things..and I gotta say I'm a fan...Erik Coxhttp://www.notionsolutions.comAnonymous
February 01, 2009
The comment has been removedAnonymous
June 09, 2009
In Visual studio 2010 Team Architect edition, you have a new type of diagram available, called the layerAnonymous
June 11, 2009
As mentioned in previous posts a huge effort of the TFS Migration tools initiative was to reverse engineerAnonymous
July 28, 2009
Cameron, I tried getting layer diagram validation to work in the build for the beta 1 version. It's not working. Validation from the diagram does work, but not in the team build (or msbuild). What I tried is this (as a delta from the procedure above)A. step 3 not needed (ArchitectureTools folder no longer there)B. step 10 did not perform the valiationAnonymous
July 28, 2009
Hey Bob,As of Beta1, steps 1 through 6 are no longer necessary.A couple of things to verifyMake sure that the layer diagram is not in the modeling project. You must put it in a code project e.g. C# class libraryMake sure the build action is set to 'Validate'. As of Beta1 this is the default, but we have some issues around copying files from 1 project to another. Make sure you add project references to all the projects that you want validated. Since this validation relies on msbuild, we need to tell msbuild what projects should be analyzed. This is achieved by creating project referencesOften it is just enough to create a project reference to the client application which tends to be on the top of the project reference hierarchy.Hope that helps. If not, let me know whats going wrong - are you seeing any errors?ThanksSuhailAnonymous
July 29, 2009
The comment has been removed