S#arp Architecture

Step 1: Upgrade S#arp Architecture

To work with the beta, you will first have to upgrade your project to work with a forked version of SharpArch. The fork includes support for Fluent NHibernate 1.0 and has a minor change to NHibernateSession that is required by the unit of work support included in S#arp Architecture Contrib. These features will likely make it into the main S#arp Architecture repository soon. Until they do, you either have to clone the fork and build it yourself or download SharpArch-bin-Release-1.0.0.zip from the download page. Either way, you have to replace all the DLLs in your project with the ones from the fork. There are a handful of breaking changes in Fluent NHibernate 1.0 that will require you to make some code changes in your project. See Tom Cabanski's blog for an explanation of what is required.

Step 2: Copy S#arp Architecture Contrib Binaries to Your Lib Folder

Copy the contents of the S#arp Architecture Contrib bin folder to your project's lib folder. Note that the the bin folder does not include S#arp Architecture binaries (see step 1).

Edit

Note: PostSharp based AOP has been replaced by Castle Interceptors, it is no longer necessary to do anything below this point

Step 3: Put PostSharp Into the Tools Folder of Your Project

Copy tools\PostSharp\*.* from the S#arp Architecture Contrib distribution or source to the tools directory of your project.

Step 4: Modify Your Projects to Use PostSharp

S#arp Architecture Contrib features other than WCF require PostSharp. PostSharp uses a post-compiler process to inject code into your assemblies when needed. You will have to modify each of the project files in your solution to call the PostSharp post-compiler. If you fail to do this, various features of S#arp Architecture Contrib will not work.

If you have the solution open in Visual Studio, close it. Then open each project file in a plain text editor and look for a line like the following:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Add a line like that shown in the following XML snippet to import the PostSharp targets immediately after the import of Microsoft.CSharp.targets shown above. You will have to change "PathToPostSharp" to the relative path from your project file to the PostSharp folder under tools. For most SharpArch projects this will be "..\..\tools".

<Import Project="PathToPostSharp\PostSharp-1.5.targets" />

The project file should now contain something like the following:

<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\..\tools\PostSharp\PostSharp-1.5.targets" />

When you re-open your solution in Visual Studio, it will warn you that the project file contains non-standard instructions. Just tell Visual Studio to open the project anyway and make sure to clear the check box that tells Visual Studio to warn you about this next time it opens a project in the current solution.

Step 5: Pre-Compile(ngen) PostSharp.exe For Best Performance

Go to the folder containing the S#arp Architecture Contrib distribution and open the tools\PostSharp folder. Double-click on "ClickToNgen.bat". This will use the .NET ngen utility to compile the .NET assembly into native code and will cache it for later use. This step should be performed once on each machine that will be used to compile your solution. This improves the performance of PostSharp almost 50% so it is quite important.

Step 6: Add the PostSharp Folder to Source Control

The contents of the PostSharp folder under your tools directory should be included in source control.

ScrewTurn Wiki version 2.0.36. Some of the icons created by FamFamFam.