NANT CSC 构建失败:参考文献丢失?
我有以下用于构建 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
建议:
在 NAnt 脚本中使用 MSBuild 来构建应用程序。
仅供参考:Visual Studio 使用 MSBuild 来编译和构建您的解决方案和项目。
可能性:
不推荐:
使用 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.
Possibility:
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.
NAnt 配置有 .NET 框架的默认 DLL 集,并且知道这些 DLL 所在的位置(例如 C:\Windows\Microsoft.NET\Framework64\v4.0.30319)。当您包含非框架程序集时,无论它们是您的还是第三方的,您都可以包含它们,但使用 DLL 的完整路径:
您还可以使用变量:
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:
You can also use variables: