mike-obrien.net Resume Blog Labs
Monday, November 26, 2007

Passing parameters to a NAnt script from CruiseControl.NET is pretty simple. Basically you pass name/value pairs with the -D command line argument in the buildArgs element. Values with spaces need to be wrapped with double quotes. The following CC.NET configuration file illustrates this:

<cruisecontrol>
     <project>
          ...
          <tasks>
               <nant>
                    <executable>C:\Program Files\nant-0.85\bin\NAnt.exe</executable>
                    <baseDirectory>F:\Build\BabelFish2.0\WorkingFolder</baseDirectory>
                    <buildArgs>-D:param1=somevalue -D:param2="some other value"</buildArgs>
                    <nologo>true</nologo>
                    <buildFile>Source/Build/Build.nant</buildFile>
                    <targetList>
                         <target>default</target>
                    </targetList>
                    <buildTimeoutSeconds>2400</buildTimeoutSeconds>
               </nant>
          </tasks>
          ...
     </project>
</cruisecontrol>

The target NAnt script need only reference the properties as follows:

<project name="YadaYadaYada" default="default">
  <target name="default">
   
<echo message="Param 1=${param1}, Param 2=${param2}"/>
  </target>
</project>

image

Monday, November 26, 2007 10:32:34 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

I've tried playing with custom configurations (Outside the stock Debug/Release configurations) in the past and found it confusing. So today I tried it again and had much better success. One thing that had me confused is the relationship between Solution level configuration and Project level configuration. What I didn't realize is that they are all completely separate entities... The "Debug" configuration in SolutionA is different from the "Debug" configuration in ProjectA. The "Debug" configuration in ProjectA is different from the "Debug" configuration in ProjectB. They all just happen to have the same name for consistency (Which is where my confusion began; guess I should have read the manual...). Although they are different entities, project level configurations can be mapped to a solution level configuration.

The example below shows a possible configuration. The solution has 2 configurations: "PlanA" and "PlanB". The BLL project have 2 configurations: "Production" and "Staging". The UI project has 2 configurations: "Red" and "Blue". The "PlanA" solution configuration has the BLL project configuration set to "Staging" while the UI project configuration is set to "Red".

image

So basically the "PlanA" and "PlanB" solution configurations represent a specific combination of project configurations. When you build a solution with a specific solution level configuration it will know what project level configuration to use with each of the individual projects in the solution. "PlanA" would use "Staging" for the BLL and "Red" for the UI.

Another thing that got me is how to add/edit/remove the project level configurations. It's pretty simple; the solution level configuration dropdown (Shown in red above) has a "<New...>" and "<Edit..>" item that enables you to modify solution level configurations. Also each individual project has a configuration dropdown (Shown in blue and green above) that give you the same options for project specific configurations.

Another thing to remember is that when you add a new project, the Debug/Release solution configurations will be automatically re-added. So if you removed these earlier they will have to be removed again.

Oh, and one more thing. Website Projects (WSP) show up as having only one option for configuration and platform with no modification options (Shown in red below). This is because configurations do not apply to a WSP (Since it isnt really a project and does not have a project file). It's a little misleading that there is one item in the list as if its assigned to it. It should just be disabled IMO. In any event it can be ignored. If you want to configure build options for a WSP, create a corresponding Web Deployment Project (WDP). You can then create configurations on the WDP that apply to the the WSP.

image

Monday, November 26, 2007 9:31:44 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Wednesday, November 21, 2007

** UPDATE ** A December 2007 CTP is available, more info here.

Looks like we will have to wait a couple of weeks for WDP support in Visual Studio 2008 as noted by Scott Guthrie:

"Two popular add-ins to Visual Studio are not yet available to download for the final VS 2008 release.  These are the Silverlight 1.1 Tools Alpha for Visual Studio and the Web Deployment Project add-in for Visual Studio. Our hope is to post updates to both of them to work with the final VS 2008 release in the next two weeks."

Wednesday, November 21, 2007 8:40:38 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

Got VS2008 Team System up and running... Only issues I ran into were needing to update the .NET Compact Framework 2.0 to SP1 and reinstalling the .NET Framework 3.0 Redist (I had this installed but something got hosed so I had to reinstall it). I ran the beta versions on a VM so I didn't have to deal with issues resulting from uninstalling betas on my dev box. I'm really liking the VM approach for evaluation! 

Rick Strahl has some interesting comments on the VS2008 install here.

Wednesday, November 21, 2007 7:00:41 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Wednesday, November 14, 2007

I guess this is a known issue with the following exception:

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'svcutil, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed. (Exception from HRESULT: 0x8013141A)
File name: 'svcutil, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' ---> System.Security.SecurityException: Strong name validation failed. (Exception from HRESULT: 0x8013141A)
The Zone of the assembly that failed was:
MyComputer

As a temporary fix you can mark the assembly to be skipped for strong name validation as follows:

sn.exe -Vr svcutil.exe

image

Wednesday, November 14, 2007 7:22:13 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 

Evidently the aspnet_compiler.exe does not care about .refresh files (From my tests and what I read on the internets). It would be nice if it did as it would reduce the steps needed to build a WSP (Web Site Project) on a build server. I ended up just manually copying the assemblies into the bin folder before the build as follows in this nant script:

<mkiisdir dirpath="..\BabelFish.ServiceHost.Web" vdirname="BabelFish.ServiceHost.Web" />

<copy todir="..\BabelFish.ServiceHost.Web\bin">
    <
fileset basedir="..\BabelFish.Services\bin">
        <
include name="*.dll" />
    </
fileset>
</
copy>

<exec program="C:\WINDOWS\Microsoft.NET\Framework\${framework.version}\aspnet_compiler.exe" useruntimeengine="true">
    <
arg value="-p" />
    <
arg value="..\BabelFish.ServiceHost.Web" />
    <
arg value="-v" />
    <
arg value="BabelFish.ServiceHost.Web" />
</
exec>

<deliisdir vdirname="BabelFish.ServiceHost.Web" />

Wednesday, November 14, 2007 6:33:25 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Tuesday, November 13, 2007

I have gotten the following exception a couple of times:

Service 'Translator' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

There are a number of things that could potentially cause this exception but the one that has gotten me a couple of times is making sure the name attribute of the service element in the .config contains the fully qualified class name. So for example if I have the following service:

namespace BabelFish.ServiceHost.Web
{
    public class Translator : BabelFish.Services.Translator
    {
    }
}

The service name should be as follows (in bold):

<configuration>
    <
system.serviceModel>
        <
services>
            <
service behaviorConfiguration="TranslatorBehavior" name="BabelFish.ServiceHost.Web.Translator">
                <
endpoint address="http://localhost/BabelFish.ServiceHost.Web/Translator.svc" binding="wsHttpBinding" name="Translator" contract="BabelFish.Services.Contracts.Service.ITranslator"/>
               <
endpoint address="mex" binding="mexHttpBinding" name="MetaDataExchange" contract="IMetadataExchange"/>
            </
service>
        </
services>
        ...
    </system.serviceModel>
    ...
</configuration>
Tuesday, November 13, 2007 4:36:39 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Monday, November 12, 2007

In order to configure WCF 3.0 to run under ASP.NET you need to run the installer (ServiceModelReg.exe) in the WFC 3.0 Framework folder (<system drive>\<windows folder>\Microsoft.NET\Framework\v3.0\Windows Communication Foundation) with the /i parameter.

image

Monday, November 12, 2007 10:49:55 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Friday, November 09, 2007

I have been wanting to dig into F# for quite some time and finally got an opportunity. My first stab at it implements the calculation of kinetic energy given a weight in lbs, speed in mph and output in kJ. Pretty basic, but ya gotta start some where right? :)

KineticEnergy.zip (.95 KB)

// Get info from the user
do Printf.printf "Enter the weight (LBS): "
let m = read_line()
do Printf.printf "Enter the velocity (MPH): "
let mph = read_line()

// Pound to kilogram conversion
let kg lbs = lbs / 2.2

// Miles/h to Meters/s conversion
let mps mph = (((mph * 1.6) * 1000.0) / 60.0) /60.0

// Kinetic energy calculation
let Ek m v = (0.5 * m * (v * v)) / 1000.0

// Show me the money
do Printf.printf "\nEk = %fkJ\n\n" (Ek (kg (float_of_string m)) (mps (float_of_string mph)))

// Wait! Let me see the answer...
do Printf.printf "Press enter to continue..."
let x = read_line()

Friday, November 09, 2007 9:52:37 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Tuesday, October 30, 2007

Below is a simple XML/XSL that displays the period table. The XML contains a number of properties not displayed by the XSL so it can be expanded.

Elements.xml (119.87 KB)
PeriodicTable.xsl (3.73 KB)

Tuesday, October 30, 2007 4:32:36 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  | 
Wednesday, October 17, 2007

Wow! And I thought MIT had a great lecture selection under OCW... Berkeley has an archive of lectures on a wide array of subjects in audio and video format. The webcast home page can be found here.

Wednesday, October 17, 2007 9:02:35 PM (GMT Standard Time, UTC+00:00)  #   |  Comments [0]  |