I'm preparing to start an Electronic Health Record (EHR) Management System (http://EHR.CodePlex.com). To ensure that the application's infrastructure is not obsolete before it is completed I am using the newest techologies available (VS2010, Azure, PRISM, MEF, Unity, etc).
The process that follows will ensure all Third-Party libraries are built and available for the new EHR application.
Unity 2.0 and MEF Beta 2 are not yet released but I'll want to take advantage of their new features. When they are released I'll have to perform this process again so I'll simplify it now. Since PRISM is dependent on Unity I'll have to upgrade it so that it is compatible with Unity 2.0. There are no dependencies on MEF but some changes have to be made because Beta 2 clashes with the version of MEF that resides in .NET 4.0.
Once I get all issues resolved so that the various projects and solutions will build I'll use a MSBuild's Copy task to transfer the .DLLs to a unified Binaries folder (c:\_\source\Binaries\Desktop). My EHR application will reference this Binaries folder as required.
I could simply place the ItemGroup and Target element directly into the applicable projects but it will be far easier to create a "CopyToBin.Desktop.Targets" file and reference it with one line of code.
[CopyToBin.Desktop.Targets] contents follow:
http://msdn.microsoft.com/en-us/library/3e54c37h.aspx
<Project DefaultTargets="AfterBuild"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<AllDll Include=".\**\*.dll" />
<CopyToBin Include="c:\_\source\Binaries\Desktop"/>
</ItemGroup>
<Target Name="AfterBuild">
<Message Text="Processing Copy Task"/>
<MakeDir Directories="@(CopyToBin)"/>
<Copy
SourceFiles="@(AllDll)"
DestinationFolder="@(CopyToBin)" />
</Target>
</Project>
I'll place the .targets files in the root of my source folder (where all my third-party source code files reside).
To easily edit the project file simply right click on the project and "Unload" it. Once unloaded you can right click on the unloaded project and select "Edit" (reference right pane in the image below). Note that I have a snippet in my Toolbox so that I can simply go to the end of the project file and insert the location of my CopyToBin.Desktop.Targets file. I'll then "Reload" the project
I'll do the above steps for all of the Unity projects and then build the project. The resulting DLLs will be copied to the Binaries\Desktop folder where I can now transfer them to the applicable PRISM folder.
PRISM stores the Unity files in it's LIB\Desktop\Unity folder. You'll have to delete the existing files and copy the newly created Unity DLLs from the Binaries folder to the above PRISM folder (later I'll have a batch file do this).
You are now ready to load the PRISM solution and compile it. There are only a few differences in Unity 1.2 and Unity 2.0 that will break the build.
-
Two projects will complain that you require a reference to System.Xaml (assuming you are also upgrading PRISM to VS2010).
-
There are a few Mock objects that do not implement interfaces correctly - simply implement the interfaces as applicable.
-
There will be two sections where you'll have to remark out code for objects that no longer exists (this is okay - I verified it with the PRISM team)
You should now be able to build PRISM using the newly compiled Unity 2.0 DLLs.
Note: To build MEF under VS2010 you'll need to follow the few steps I noted in the MEF Developers forum (CLICK HERE)
Once I have all of my projects setup with the new CopyToBin.Desktop.target I can run the batch files I created. The first, BuildBinaries.cmd, will launch the Visual Studio 2010 command window - its contents follow:
@ECHO OFF
echo Type - and hit ENTER
call %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
This batch file is the one provided by Visual Studio which sets up the environment (otherwise the second batch file won't find MSBuild). It effectively opens a Visual Studio Command window so that you can easily run the second batch file "-.cmd" (dash - keep it quick/simple).
The -.cmd batch file is based on folder structures compatible with the third-party applications. The batch file will change directories to each of the applicable solutions and then run MSBuild against it.
Note: I renamed the folders since doing the above screenshot to ensure I wouldn't have to modify the batch file later (I'll just simply ensure updates use the names used).
The end results is a I have a Binaries folder that is populated with all of the Third-Party DLLs that I will be using for my application. When new releases are provided I simply have to ensure they compile and then run my batch file again.
Tags:
prism,
msbuild
Categories:
CompositeWPF