MacBook Pro

I ordred a MacBook Pro (13 inch model) during the weekend, reconfigured it to come with 4gb ram, so with alot of luck i'll have it before the next weekend. So just a heads up that there will be a bit more ruby, mac etc on the blog and some more Android.

.Net 3.5 / Silverlight cross compiling (sort of)

I'm working on a Silverlight/WCF project where I wanted to share my DataContract classes between the WCF service and the Silverlight client, so that changing the contract would break the client, instead of giving errors at run time. The other way of doing this is using the add as link feature, but since I have a lot of different classes that seemed like a lot of work. A Silverlight project has the following target:
<Import Project="$(MSBuildExtensionsPath)\Microsoft\
   Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" />
A .Net 3.5 CLR project has this target:
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
So what I want is to have both targets in the csproj file and when I build the project output 2 dll's one for Silverlight and one for my .Net 3.5 clr project. Since Visual Studio doesn't care about the condition attribute on a import node in the project file (it always takes the first node in the file) I needed some other way of choosing what configuration to build. The solution I found was to add a new configuration to the project called CLR, and then edit my csproj file and add some bits.
<Import Project="$(MSBuildExtensionsPath)\Microsoft\
   Silverlight\v2.0\Microsoft.Silverlight.CSharp.targets" Condition=" '$(Configuration)' != 'CLR' " />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" Condition=" '$(Configuration)' == 'CLR' " />
Now I have both import nodes in the csproj file, since Visual Studio always uses the first target file (Silverlight in this case) this limits the intellisense to the Silverlight CLR, the second one is for building my 3.5 dll. So to make this work I had to add a AfterBuild task.
<MSBuild Projects="$(MSBuildProjectFile)" Properties="Configuration=CLR;Platform=AnyCPU" Targets="Build" ContinueOnError="true" />
This will simply build the project again but with the configuration param set to CLR, I also needed to modify the target and add a condition so that I don't get stuck in a build loop. The full target looks like this:
<Target Name="AfterBuild" Condition=" '$(Configuration)' != 'CLR' ">
<MSBuild Projects="$(MSBuildProjectFile)" Properties="Configuration=CLR;Platform=AnyCPU" Targets="Build" ContinueOnError="true" />
</Target>
To be able to use this I simply added the class library as a project reference to other Silverlight project and a reference to the CLR dll for the .Net 3.5 projects. This way I get both ddl's on every build and all projects haveĀ  the same contract. Also if needed I can use the #if SILVERLIGH compiler switch to add code specific to either SilverLight or .Net 3.5.

HTC Magic

Picked up an HTC Magic yesterday, only used it for a day but I've already decided that it's the best phone I've ever used. The Android OS is fast and looks better in reality than in the images I've seen. Right now I'm filling it with cool apps and mostly playing around but next thing to do is to install Eclipse and the Android SDK so I can start developing apps.

note to self

A short one. Just so I don't forget, then again Subversion never forgets! Don't use SchemaExport on existing dbs, it breaks them!
if(!File.Exists("episkfail.db"))
    new SchemaExport(cfg).Execute(false, true, false, false);
and yes, it's a part of my twitter client that I code a bit on when I got nothing better to do =)