Sunday 6 June 2010

Building S#arp Architecture fails with a Nant error

 

I am having a look at S#arp architecture.  I downloaded the latest build (1.5.2) and proceeded to start the build by clicking ClickToBuild.bat, which instantly failed with:

NAnt 0.86 (Build 0.86.2898.0; beta1; 08/12/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

BUILD FAILED

Failed to initialize the 'Microsoft .NET Framework 2.0' (net-2.0) target framework.

    Property evaluation failed.
Expression: ${path::combine(sdkInstallRoot, 'bin')}
                            ^^^^^^^^^^^^^^

        Property 'sdkInstallRoot' has not been set.

For more information regarding the cause of the build failure, run the build again in debug mode.

Try 'nant -help' for more information

Not sure why but it might be an issue with the version of Nant bundled with S#arp.

Not really having a clue as to how to fix this I installed the .Net 3.5 SDK and tried again, no joy. 

Then I installed the .Net 2.0 SDK, this progressed past the above error, but then I got:

NAnt 0.86 (Build 0.86.2898.0; beta1; 08/12/2007)
Copyright (C) 2001-2007 Gerry Shaw
http://nant.sourceforge.net

Buildfile: ***************
Target framework: Microsoft .NET Framework 2.0
Target(s) specified: build

[property] Target framework changed to "Microsoft .NET Framework 3.5".

BUILD FAILED

INTERNAL ERROR

System.NullReferenceException: Object reference not set to an instance of an object.
   at NAnt.Core.FrameworkInfo.get_Version()
   at NAnt.Core.Project.UpdateTargetFrameworkProperties()
   at NAnt.Core.Tasks.PropertyTask.ExecuteTask()
   at NAnt.Core.Task.Execute()
   at NAnt.Core.Project.InitializeProjectDocument(XmlDocument doc)
   at NAnt.Core.Project.Execute()
   at NAnt.Core.Project.Run()

At this point, I abandoned open source software and went back to webforms :0

Only joking, google found me this which pointed me in the right direction of editing the {S#arp root folder}tools\nant.exe.config file.

At this point I’m not sure if you actually need either the 2.0 or the 3.5 SDK. 

The post wasn’t an exact match (I’m x64 and VS 2010) but by comparing the windows Registry with the nant config file I managed to get S#arp built.

Here is what eventually worked for me (YMMV), but essentially the nant file has to point to a valid registry key for an SDK:

   1: <readregistry
   2: property="sdkInstallRoot"
   3: key="SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx35Tools\InstallationFolder"
   4: hive="LocalMachine"
   5: failonerror="false" />

 

Happy S#arping!