NANT CSC 构建失败:参考文献丢失?

发布于 2024-12-05 11:53:09 字数 1376 浏览 1 评论 0原文

我有以下用于构建 winexe 的 NANT CSC 目标:

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

以下是失败消息:

  D:\..\myClass.cs(9,17): error CS0234: The type or namespace name 'Reporting' 
     does not exist in the namespace 'Microsoft' (are you missing an assembly 
     reference?)

在 myClass.cs 中,我有以下使用参考:

using Microsoft.ReportViewer.WinForms;

在 VS 中构建我的应用程序没有问题,但我无法从 NANT 构建。我认为我可能会错过 NANT 构建中对 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 是控制台中的构建应用程序,并且不了解全局缓存中的引用。

I have the following NANT CSC target for building 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>

The following is the failure message:

  D:\..\myClass.cs(9,17): error CS0234: The type or namespace name 'Reporting' 
     does not exist in the namespace 'Microsoft' (are you missing an assembly 
     reference?)

In myClass.cs, I have this using reference:

using Microsoft.ReportViewer.WinForms;

There is no problem to build my app in VS, but I could not build from NANT. I think that I may miss reference to Microsoft.ReportViewer.WinForms.dll in NANT build. Not sure how I can include this dll in my bin for NANT?

I have tried to modify csc target's references:

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

Still not working. Should I use COPY target to copy all the dll files from bin to $(build.dir)?

Updates: I found that those Microsoft.ReportViewer.xx.dll files in project references are not copy to local. How can I simulate copy to local in NANT for those two dll files? I guess that may resolve the issue since NANT is a build app in console and does not have knowledge about references in global cache.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

挽心 2024-12-12 11:53:10

建议:

  • 在 NAnt 脚本中使用 MSBuild 来构建应用程序。

    仅供参考:Visual Studio 使用 MSBuild 来编译和构建您的解决方案和项目。

    
    <属性名称=“MSBuildPath”值=“C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe”/>    
    <目标名称=“构建”>
        <执行程序=“${MSBuildPath}”>
            ;
            
            >
            >
        
    
    

可能性:

  • 在本地复制引用/文件(即使用复制任务)。或者类似地在包含名称中使用完整路径。

不推荐:

  • 使用 NAnt 的“solution”任务,或 NAntContrib 的“msbuild”任务。

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

希望有帮助。

Recommended:

  • Use MSBuild in your NAnt script(s) to build your application.

    FYI: Visual Studio uses MSBuild to compile and build your solution and projects.

    <!-- 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>
    

Possibility:

  • Copy references/files locally (i.e. using copy task). Or similarly use full paths in the include name.

Not recommended:

  • Use NAnt's "solution" task, or NAntContrib's "msbuild" task.

    This would simplify the msbuild call but would tie you into older versions of msbuild/VS solution/project files. Newer VS solution/project files would not be supported readily.

Hope it helps.

你怎么这么可爱啊 2024-12-12 11:53:09

NAnt 配置有 .NET 框架的默认 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>

NAnt is configured with the default set of DLLs for the .NET framework, and knows where those DLLs reside (e.g. C:\Windows\Microsoft.NET\Framework64\v4.0.30319). When you include non-framework assemblies, whether they are yours or a 3rd party, you can include them, but use the full path of the DLL:

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

You can also use variables:

<property name="common.directory" value="C:\Common" />
...
<csc ...>
   ...
   <references>
      <inclde name="${common.directory}\ThirdParty.dll" />
   </references>
</csc>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文