At work we use CruiseControl.net + Nant for our continuous integration. Recently we have upgrades to VS2010 and .Net 4.0 (awesome so far). Alas, as soon as we converted our solution to .Net 4.0, our build server broke! After googling and wrestling for 2 days with build errors, I finally got the build server running again. I found most of my questions on Stack overflow, however I had this "AL exited with code 128" build error that I could not get past and it was driving me crazy! So, below are the steps to upgrade to .Net 4.0 and to solve the "AL" error message (that hopefully you won't get):
First thing. You DO NOT need to intall VS2010 in the build server like many people think. You do have to install the latest Windows SDK. (I believe 7.0)
1) Install .Net 4.0 Framework.
2) Install latest Windows SDK.
Install the latest Windows SDK, then go to the registry and copy the key "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0" and rename all instances of 7.0 to 7.0A. The Build server is going to look at that path in order to get the "Installation Folder key". Alternatively, You can copy the text below into a notepad and save it as "whatever.reg", then run it and it should import the key and subfolders into the registry.
*~~~~~~~~~~~~~~~~~~~~ Copy everything below this line ~~~~~~~~~~~~~~~~~~~~~~
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\"
"ProductVersion"="7.0.30319"
"ProductName"="Microsoft Windows SDK for Visual Studio 2010"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx35Tools]
"ProductVersion"="7.0.30319"
"ComponentName"="Windows SDK .NET Framework 3.5 Multi-targeting Utilities"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-NetFx40Tools]
"ProductVersion"="7.0.30319"
"ComponentName"="Windows SDK Tools for .NET Framework 4.0"
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\NETFX 4.0 Tools\\"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-SDKTools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\"
"ProductVersion"="7.0.30319"
"ComponentName"="Windows Common Utilities"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-Win32Tools]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\Bin\\"
"ProductVersion"="7.0.30319"
"ComponentName"="Windows Utilities for Win32 Development"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-WindowsHeadersLibs]
"InstallationFolder"="C:\\Program Files\\Microsoft SDKs\\Windows\\v7.0A\\"
"ProductVersion"="7.0.30319"
"ComponentName"="Windows Headers and Libraries"
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A\WinSDK-WinSDKIntellisenseRefAssys]
"InstallationFolder"="C:\\Program Files\\Reference Assemblies\\"
"ProductVersion"="7.0.30319"
"ComponentName"="Windows Intellisense and Reference Assemblies"
*~~~~~~~~~~~~~~~~~Do not include this line~~~~~~~~~~~~~~~~~~~~~
3) Modify your Nant.exe.config file.
Towards the end of your Nant.exe.config file, modify the <startup> section to add .Net 4.0 as a supported Runtime:
<supportedRuntime version="v4.0.30319" />.
Also, under the <properties> section, add a property:
<property name="nant.settings.currentframework" value="net-4.0" />
This will make your builds default to that framework. You can also put this property in your projects Nant file, so you can tell each project what version to target. Finally, you need to add the .net4.0 framework node. Here is a link to that configuration section: http://pastebin.com/3ghS0gyA
4) Review the Build section of your Nant file
I was using the msbuild task for NantContrib. That still works, but if it doesn't, you can always use the <exec> task and call msbuild.exe like so:
<property name="msbuild.exe" value="C:\WINDOWS\Microsoft.NET\Framework\v4.0\MSBuild.exe" />
<exec program="${msbuild.exe}">
<arg line="/property:Configuration=${YourSolutionConfigurationHere}" />
<arg line='"${YourSolutionFileFullPathHere}"' />
<arg value="/target:Rebuild" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
</exec>
5) Random Errors
I ran into some weird build errors: "error MSB6006: "AL.exe" exited with code 128" That's it, not helpful at all. I did some googling and came up with few answers. Here are the links: msdn help and asp.net forums. I wrestled with that error for a full day, studying the "detailed" and "diagnostic" logs, but all it did is pointing me to the assembly that failed building. No specific error. I could not even duplicate it on my local box.
Finally, I decided to try the suggestion about the "resource" files naming convention in the asp.net forum link, and... alleluia! my build started working. I don't know what's up with the build failing because of the resource name, still working on that, but my immediate goal was to get the build working.
StackOverflow related posts:
http://stackoverflow.com/questions/1215731/building-net-4-projects-with-nant
http://stackoverflow.com/questions/2353404/nant-msbuild-task-with-net-4-0-rc
http://stackoverflow.com/questions/1291221/going-from-solution-to-exec-programmsbuild-in-nant
Hope this helps someone else out there.
-D