使用 .csproj 文件的 C# nant 构建
通常,在为 C# 编写构建脚本时,我只为要构建的每个项目/dll 包含 **/*.cs。但是,我现在遇到的情况是,我有一些 .cs 文件,这些文件不属于项目的一部分,但位于该目录中(它们是为了来自另一个库的参考目的)。 .csproj 文件中没有链接,因此 VS 构建工作正常,但 nant 构建则不然。
有谁知道是否有一种简单的方法可以从相关的 .csproj 文件中提取 .cs 条目并将其用作要构建的源文件列表,而不是使用一般的通配符匹配。
提前致谢。
Typically when doing a build script for C# I just include **/*.cs for each project/dll to build. However I now have a situation where I have some .cs files which are not part of the project but live in that directory (they are there for reference purposes from another library). There are not linked in the .csproj file so the VS build works fine but the nant build does not.
Does anyone know if there's a nice easy way of pulling the .cs entries out of the relevant .csproj file and using that as the list of source files to build rather than using a general wildcard match.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您不想将 msbuild 仅用于 C# 构建位有什么特殊原因吗?这就是我为 Protocol Buffers 端口所做的事情,而且效果很好。它确实需要nant-contrib,但这并不是什么困难。
这样您就知道您只需要让一件事发挥作用,并且知道它将以相同的方式构建。
您可以查看我的 ProtoBuf 端口构建文件 这里,寻找灵感。明显的缺点是 Mono 支持,但我相信 xBuild 正在改进......
Any particular reason you don't want to use msbuild just for the C# build bit? That's what I do for my Protocol Buffers port, and it works well. It does require nant-contrib, but that's not much of a hardship.
That way you know you only need to get one thing working, and know it'll be built the same way.
You can have a look at my ProtoBuf port build file here, for inspiration. The obvious downside is Mono support, but I believe xBuild is improving...
nant 支持自动构建 VS 解决方案,包括
csproj
文件,使用
任务。最新支持的解决方案格式是 VS 2003。
nant has support for automatically building VS solutions, including
csproj
files, using a<solution>
task.The latest supported solution format is VS 2003.
Nantcontrib 包括 msbuild 任务 - 您可以使用它来构建项目和解决方案。这是实践中的一个示例: http://web.archive.org/web/20100913051600/http://codebetter.com/blogs/jeffrey.palermo/archive/2006/08/12/148248.aspx< /a>
Nantcontrib includes an msbuild task - you can use this to build both projects and solutions. Here's an example of it in practice: http://web.archive.org/web/20100913051600/http://codebetter.com/blogs/jeffrey.palermo/archive/2006/08/12/148248.aspx
您可以通过 Exec 任务使用 MSBuild 构建项目,而不是直接调用编译器,例如
msbuild project.csproj
。You could build the project using MSBuild via an Exec task instead of invoking compiler directly e.g.
msbuild project.csproj
.使用 MSBuild 是个好主意。但是,如果存在任何孤立文件(.cs 文件不在 .csproj 中),aspnet_compile.exe 有时会失败。为了解决这个问题,我编写了以下内容来删除 .csproj 中未包含的所有 *.cs 文件。到目前为止一切顺利,欢迎任何反馈。
Using MSBuild is a great idea. However, if there are any orphaned files (.cs files not in .csproj), aspnet_compile.exe will sometimes fail. To get around this I wrote the following to remove all *.cs files that are not included in the .csproj. So far so good, any feedback is appreciated.