Friday, May 23, 2008

Infragistics and the build server

We use Infragistics third party controls (NetAdvantage for Windows Forms 2008 Vol. 1 Bundle) and we had some problems with getting this to work on the build server. We have a clean build server without any software installed except CruiseControl and Subversion, we copy the dll to a library folder and link them from there. We use CruiseControl, nAnt and MSBuild for the build. The reason for using a clean build server is to make sure that the build isn’t dependent of any strange version of a dll or program installed by any developer or technician.

Infragistics recommends the users to install the Infragistics product on the build server. If you can’t do that you got two problems. First you will have a problem with the missing link to LC.exe.

Error message from MSBuild:
“C:\WINDOWS\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets (1734,9): errorMSB3091: Task failed because "LC.exe" was not found, or the correct Microsoft Windows SDK is not installed. The task is looking for "LC.exe" in the "bin" subdirectory beneath the location specified in the InstallationFolder value of the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v6.0A. You may be able to solve the problem by doing one of the following: 1) Install the Microsoft Windows SDK for Windows Server 2008 and .NET Framework 3.5. 2) Install Visual Studio 2008. 3) Manually set the above registry key to the correct location. 4) Pass the correct location into the "ToolPath" parameter of the task.

Solution: Just add the ToolPath and where the LC.exe file is located in the build script.

<exec program="${msbuild.executable}" workingdir="${msbuild.workingdir}" commandline="${msbuild.VPSfile.path}" append="true" verbose="true"> …<arg value="/p:configuration=${msbuild.build.configuration};TargetFrameworkVersion=v${msbuild.targetframework};LCToolPath=C:\svnwork\dev\tools\Microsoft" /> … </exec>

Then you got the license.licx error. “LC (,): errorLC0000: 'Could not find file
'C:\svnwork\...\UserInterface.Windows\Properties\licenses.licx'.'”
You have two different solutions to this problem. First you can just remove the file from the project and it will work. The problem with this solution is that every time you open a form the licx file will be created and the file will be back in the Properties folder in your project. Solution two is to have an empty licx file in the project. Now it works if you just don’t check in the changes of the licx file.

I asked Infragistics about our solution and I got this answer: “As far as build servers are concerned, the recommended practice is to install the NetAdvantage product on the machine. As you have already noted, the License Compiler (LC.exe) will failed if you attempt to compile a project using just the NetAdvantage assemblies. This is due to the fact that our licensing is design-time and compile-time licensing. When a project is compiled, the License Compiler will process each entry within the licenses.licx file, verifying the component/control has a valid license.

As you have also noticed, the project will build successfully if the licenses.licx file is excluded from the project. If there is no licenses.licx file included in the project or the licenses.licx file is empty, the build will succeed. We have suggested this in the past to the customers who are prohibited from installing the product on the build server. We recommend installing the product as Visual Studio will include and repopulate the licenses.licx file whenever a form/page utilizing NetAdvantage controls is viewed in the designer.

3 comments:

Chris said...

I just stumbled upon this issue and had a different solution that I thought may interest some of your readers.

I first referenced the Infragistics assemblies as local assemblies (not in the GAC), which are part of the source tree. Then I modified the TFSBuild project file to call a batch file after retrieving the source from source control. The batch file then overwrites each license file in the tree with an empty file.

Here are the details:

First the TFSBuild project file:
<Target Name="AfterGet">
<BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Message="Clearing Licenses.licx files...">
<Output TaskParameter="Id"
PropertyName="ClearLicensesStepId"/>
</BuildStep>
<Exec Command="EmptyLicenseFiles.bat $(SolutionRoot)" WorkingDirectory="$(SolutionRoot)\TeamBuildTypes"/>
<BuildStep TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
BuildUri="$(BuildUri)"
Id="$(ClearLicensesStepId)"
Status="Succeeded"/>
</Target>


Here is the batch file:

REM Create an Empty licx file
echo. 2>empty_licenses.licx

REM Loop through each licx file and copy the empty license file over the existing file
for /f %%a IN ('dir /b /s %1*.licx') do copy /Y empty_licenses.licx %%a

REM Remove the Empty licx file
del empty_licenses.licx

Gurpiar Singh said...

Thank you man! I tried everything,nothing worked. But this worked, and I am so thankful to you. MSBuild accepts LCToolPath, that's amazing.

Jay said...

Creating an empty licenses.licx file works great, but I am a bit confused as this seems like such an incredibly simple workaround to the whole .Net licensing scheme.

Doesn't this mean that you could simply grab copies of the Infragistics .dlls that have been distributed with someone else's application, and then incorporate them into your own application without needing to obtain an Infragistics license?

Or is there something I'm missing?