MSBuild - 使用.csproj文件或滚动自己的? [英] MSBuild -- Use the .csproj file or roll your own?

查看:221
本文介绍了MSBuild - 使用.csproj文件或滚动自己的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我很容易承认,我是一个新手,当谈到持续集成。

OK, so I readily concede that I'm a newbie when it comes to continuous integration.

话虽如此,我想设立一个CC .NET环境教育自己,但我无法找到我需要的信息,以获得自动构建部分设置。

That being said, I'm trying to set up a CC.NET environment to educate myself, but I'm having trouble finding the information I need to get the automated build portion set up.

根据我的理解,在C# VS 2005生成的.csproj文件和转发有效的MSBuild文件。也就是说,我已经能够使用.csproj文件将MSBuild任务集成到CC.NET中,但是我遇到了一些问题:

As I understand it, in C# the .csproj file produced by VS 2005 and forward is a valid MSBuild file. To wit, I've been able to integrate the MSBuild task into CC.NET using the .csproj file, but I have a few issues with this:


  1. 这里有很多事情,我不知道我真的需要在自动化的构建环境。

  2. 我没有创建这个文件。我不明白,这让我害怕。 (通过一致性编程

  3. 正在进行的大多数操作似乎是通过 $(MSBuildToolsPath)\Microsoft.CSharp.targets

  4. 结果1,2和3,修改文件包括像MbUnit似乎令人费解和更困难比它需要。我唯一真正的选择是将它包含在 AfterBuild 部分,这似乎是一个对我的黑客。
  1. There's a lot going on in here that I'm not sure I really need in an automated build environment.
  2. I didn't create this file. I do not understand it, and that scares me. (Programming By Coincidence)
  3. Most of what is going on seems to be abstracted through $(MSBuildToolsPath)\Microsoft.CSharp.targets
  4. As a result of 1, 2, and 3, modifying the file to include something like MbUnit seems convoluted and more difficult than it needs to be. My only real option is to include it in the AfterBuild section, which seems kind of like a hack to me.

所以,对于CC.NET的人,MSBuild的人和MbUnit的人有几个问题。

So, a few questions for the CC.NET folks, the MSBuild folks, and the MbUnit folks.


  1. 使用MSBuild时,是否建议使用VS生成的.csproj文件作为构建文件?

  2. MbUnit测试应该是MSBuild文件还是CC.NET文件的一部分?我的研究似乎暗示他们属于MSBuild文件。如果是这样,我是否创建一个新的MSBuild .proj文件,并检查到CVS除了.csproj文件?或者MbUnit任务是否成为我的.csproj文件的一部分?

  3. 与问题2类似。如果我将MbUnit测试添加到MSBuild文件,最后使用.csproj文件, 目标名称=AfterBuild真的要添加该信息的部分吗?是否应该有 Target Name =Test部分?使用VS生成的.csproj文件似乎阻止了第二个选项。

  1. When using MSBuild, is it advisable to use the VS-generated .csproj file as the build file? Or should I create my own?
  2. Should MbUnit tests be part of the MSBuild file or the CC.NET file? My research seems to suggest that they belong in the MSBuild file. If that is the case, do I create a new MSBuild .proj file and check that in to CVS in addition to the .csproj file? Or does the MbUnit task become part of my .csproj file?
  3. Similar to question 2. If I add the MbUnit tests to the MSBuild file and end up using the .csproj file, is the Target Name="AfterBuild" really the section to add that information? Shouldn't there be a Target Name="Test" section? Using the VS generated .csproj file seems to prevent the second option.

我知道有很多,我已经能够在网上找到一些熟悉这些话题,我只是没有 - 除非我错了,这个东西的学习曲线不是一个曲线,它是一个阶跃函数。 :)

I know there's a lot there, but most of what I've been able to find online assumes a certain level of familiarity with these topics that I just don't have -- unless I'm mistaken, the learning curve for this stuff isn't a curve at all, it's a step function. :)

编辑1:我更新了文本更简洁,解决了我对答案的一些留下的问题。

Edit 1: I updated the text to be a bit more concise and to address some lingering questions I've had with the answers.

推荐答案

我建议使用生成的.csproj文件 - 事实上生产,我认为使用生成的.sln文件是一个好主意。我发现,你将获得使用与开发人员相同的解决方案文件。

I would recommend using the generated .csproj files - in fact for production, I think using the generated .sln files is a good idea. I have found that you will you gain by using the same solution files as the developers.

注意.sln文件实际上并不是有效的msbuild项目文件 - 他们被转换当它们用作输入时,由msbuild自身转换为msbuild项目。 Tricky!

Be aware that .sln files are not actually valid msbuild project files - they are transformed into msbuild projects by msbuild itself when they are used as inputs. Tricky!

出于学习目的,你可能需要记录.csproj的构建,然后逐步了解发生了什么。

For learning purposes, you may want to log the build of a .csproj and step through to get an idea of what is going on. MSBuild is a bit more declarative than nant though, so take your time and experiment a bit.

最后,我会将.sln或.csproj文件包含在一个连续的构建中脚本项目与msbuild任务一起构建项目并一起运行单元测试。这样,开发人员不必在每次构建时运行单元测试 - 但每次他们集成代码时,单元测试都将运行。是的,确保他们跑得快!任何花费超过一秒钟的时间应该在计划(每夜?)构建期间运行。

Finally, I would wrap your .sln or .csproj files in a continuous build script project with msbuild tasks to build your projects and run your unit tests together. This way the developers don't have to run the unit test every time they build - but every time they integrate their code the unit tests will run. And yes, make sure they run fast! Anything that takes more than a second should be run during a scheduled (nightly?) build instead. Likely they are less unit tests and more integration tests written with a unit test framework if they take more than a second.

编辑:一些附加功能信息我发现我发现有用 - 使用MSBuild 3.5将允许您从.sln文件获取目标输出,而此信息不在MSBuild 2.0中返回(虽然我认为它应该工作在两个版本的.csproj文件)。您可以使用输出(您的构建文件)作为您的单元测试框架的输入。

Some addition information I have found that I have found useful - using MSBuild 3.5 will allow you to get the target output from a .sln file, while this information is not returned in MSBuild 2.0 (though I think it should work for .csproj files in both versions). You can use the output (your built files) as inputs to your unit testing framework.

这篇关于MSBuild - 使用.csproj文件或滚动自己的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆