tirsdag den 21. oktober 2014

Parameter "AssemblyFiles" has invalid value

Issue

When  referencing an assembly the compiler fails with this error

 error MSB3248: Parameter "AssemblyFiles" has invalid value "C:\CruiseControl\...\myAssembly.dll". Culture is not supported. [C:\CruiseControl\Projects\TemplateSite\WebApp\WebApp.csproj]  
 error MSB3248: Parameter name: name [C:\CruiseControl\..\WebApp.csproj]  
 myAssembly is an invalid culture identifier. [C:\CruiseControl\..\WebApp.csproj]  

Cause

This is caused by an invalid value in the AssemblyCulture attribute in the Assembly.cs

 [assembly: AssemblyCulture("myInvalidValue")]  

Solution

Set the AssemblyCulture to a valid value e.g. en-US or da-DK or just set it to default


 [assembly: AssemblyCulture("")]  

torsdag den 16. oktober 2014

How to prevent NAnt task returning code 3 to fail full buildprocess

Issue

The issue is that my buildscript fails because a task returns a code different from 0 even though the executable succeeds.

The buildscript contains a task that copies my website to a development server.
I use RoboCopy.exe to do this.

The task looks like this

  <target name="upload" depends="release"> 
   <exec 
    program="${robocopy}" 
    commandline=".\Website ${devroot}\www ${robocopyUploadArgs}" 
           /> 
  </target> 

However RoboCopy has a set of codes it can return depending on how many files were copied. See http://ss64.com/nt/robocopy-exit.html for more info.
Here it tells that a return value below 9 is a success.

Solution

By specifying to parameters; failonerror="false" and resultproperty="return.code" it is possible to tell NAnt that we dont want to fail on error but want the exit-code to be put in a property named return.code. Following a simple <if> task enables us to test and fail if the return code is larger than 8.
The script now looks like this (remember to add property named return.code)