3
votes

I've got my .build setup

<csc platform='x86' target='winexe' output='${validate.file}' debug='${debug}' warnaserror='true'>

but I get

  [csc] error CS1607: Warning as Error: Assembly generation -- Referenced assembly 'System.Data.dll' targets a different processor
  [csc] error CS1607: Warning as Error: Assembly generation -- Referenced assembly 'System.Data.OracleClient.dll' targets a different processor
  [csc] error CS1607: Warning as Error: Assembly generation -- Referenced assembly 'System.EnterpriseServices.dll' targets a different processor
  [csc] error CS1607: Warning as Error: Assembly generation -- Referenced assembly 'System.Transactions.dll' targets a different processor
  [csc] error CS1607: Warning as Error: Assembly generation -- Referenced assembly 'System.Web.dll' targets a different processor
  [csc] error CS1607: Warning as Error: Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor

External Program Failed: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe (return code was 1)

when I use NAnt .92. If I use NAnt .91 everything works. How do I update my .build to work with .92? I'm building on Win7 64Bit.

Under NAnt .91 with the exact same .build file, the external program used is C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe. Note the Framework, not Framework64. It looks like NAnt .92 uses the wrong framework when plateform='x86' is selected.

1
This is probably better suited as a bugreport on the NAnt-devel mailing list: mail-archive.com/nant-developers%40lists.sourceforge.net - skolima
I sent an email to the list, no idea if it will go through as I didn't sign-up. I really don't want to get all the nant emails. - Justin808

1 Answers

0
votes

One simple workaround is to modify your csc task like this:

<csc platform='x86' target='winexe' output='${validate.file}' debug='${debug}' warnaserror='true'>
    <warnaserror>
        <exclude number="1607" />
    </warnaserror>

This way you still get warnings as errors (which is what you want I guess) but not the CS1607 in particular. Maybe it's a compromise you can live with?

It is indeed an interesting issue. Diving into NAnt.exe.config, I see that the definition of the framework 'net-4.0' always looks up its assemblies in:

frameworkdirectory="${path::combine(installRoot, 'v4.0.30319')}"
frameworkassemblydirectory="${path::combine(installRoot, 'v4.0.30319')}"

and installRoot comes from the registry, which always has the value Framework64. What this means is that by the time you've targeted 'net-4.0', you've already selected the Framework64 folder. By the time you specify in the csc task that it's supposed to use x86, it's too late.

A nice and daring experiment would be to create a new framework definition inside NAnt.exe.config, duplicating net-4.0 into, let's say, net-4.0-x86. Then change that definition to target the Framework path instead of the Framework64. It might work. Of course then you'll need to tell nant to target net-4.0-x86 and you'll have a hacked customized NAnt.exe.config file.