3

我有我的 .build 设置

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

但我明白了

  [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)

当我使用 NAnt .92 时。如果我使用 NAnt .91 一切正常。如何更新我的 .build 以使用 .92?我正在构建 Win7 64 位。

在具有完全相同的 .build 文件的 NAnt .91 下,使用的外部程序是C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe. 请注意框架,而不是 Framework64。看起来 NAnt .92plateform='x86'选择时使用了错误的框架。

4

1 回答 1

0

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.

于 2012-08-27T11:35:31.067 回答