Msbuild NANT CSC生成失败:缺少引用?

Msbuild NANT CSC生成失败:缺少引用?,msbuild,c#-3.0,nant,csc,Msbuild,C# 3.0,Nant,Csc,我有以下NANT CSC建设winexe的目标: <csc target="winexe" output="${Deploy.dir}\VMIS.exe" debug="${debug}"> <sources> <include name="${App.dir}\**\*.cs" /> <include name="${Build.dir}\AssemblyInfo.cs" /> <exclude name="${App

我有以下NANT CSC建设winexe的目标:

<csc target="winexe" output="${Deploy.dir}\VMIS.exe" debug="${debug}">
  <sources>
   <include name="${App.dir}\**\*.cs" />
   <include name="${Build.dir}\AssemblyInfo.cs" />
   <exclude name="${App.dir}\**\AssemblyInfo.cs" />
  </sources>
  <references refid="Lib.fileset">
  </references>
  ...
</csc>
在myClass.cs中,我使用了以下引用:

using Microsoft.ReportViewer.WinForms;
在VS中构建我的应用程序没有问题,但我无法从NANT构建。我想我可能没有在NANT build中引用Microsoft.ReportViewer.WinForms.dll。不确定如何将此dll包含在NANT的bin中

我已尝试修改csc目标的参考:

<csc ...>
  ...
  <references refid="Lib.fileset">
    <include name="Microsoft.ReportViewer.Common.dll" />
    <include name="Microsoft.ReportViewer.WinForms.dll" />
  </references>
  ...
</csc>

...
...
仍然不起作用。我应该使用COPY target将所有dll文件从bin复制到$(build.dir)吗

更新:我发现项目引用中的那些Microsoft.ReportViewer.xx.dll文件没有复制到本地。如何在NANT中为这两个dll文件模拟复制到本地?我想这可能会解决问题,因为NANT是控制台中的构建应用程序,不了解全局缓存中的引用。

建议:

  • 在NAnt脚本中使用MSBuild生成应用程序

    仅供参考:VisualStudio使用MSBuild编译和生成解决方案和项目

    <!-- Verify the right target framework -->
    <property name="MSBuildPath" value="C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe" />    
    <target name="Build">
        <exec program="${MSBuildPath}">
            <arg line='"${SolutionFile}"' />
            <arg value="/target:Rebuild" />
            <arg value="/verbosity:normal" />
            <arg value="/nologo" />
        </exec>
    </target>
    
    
    
可能性:

  • 本地复制引用/文件(即使用复制任务)。或者类似地,在include名称中使用完整路径
不建议:

  • 使用NAnt的“解决方案”任务或NAntContrib的“msbuild”任务

    这将简化msbuild调用,但会将您绑定到旧版本的msbuild/VS解决方案/项目文件中。较新的VS解决方案/项目文件将不受支持


希望有帮助。

NAnt配置了.NET framework的默认DLL集,并且知道这些DLL驻留在哪里(例如C:\Windows\Microsoft.NET\Framework64\v4.0.30319)。当包含非框架程序集时,无论它们是您的还是第三方的,您都可以包含它们,但要使用DLL的完整路径:

<include name="C:\Common\ThirdParty.dll" />

您还可以使用变量:

<property name="common.directory" value="C:\Common" />
...
<csc ...>
   ...
   <references>
      <inclde name="${common.directory}\ThirdParty.dll" />
   </references>
</csc>

...
...

装配信息文件如何?哪个是共享的
<property name="common.directory" value="C:\Common" />
...
<csc ...>
   ...
   <references>
      <inclde name="${common.directory}\ThirdParty.dll" />
   </references>
</csc>