有什么优点和优点?为 .Net 中的每个项目创建自动构建系统有何缺点?
刚刚花费了令人沮丧的时间使用 psake 配置自动构建后,我突然想到为什么不使用我最了解的语言来创建构建器?
psake 是创建自动化构建的优秀框架。我一直遇到的麻烦是学习 powershell 来运行更复杂的任务。我确信 NAnt、msbuild 等也可以这样说。
我解决这个问题的想法是为 .Net 中的给定解决方案创建构建系统。该过程的基本结构如下:
build.bat
rem // Set the environment for msbuild.
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
rem // Build the solution's builder.
msbuild.exe buildsolution.csproj
rem // Run the solution's builder.
BuildSolution.exe <task>
项目的 BuildSolution
一个小型控制台应用程序:
- 引用 BuildSolution 框架。
- 包括每个任务的方法。例如:
- 干净
- 构建
- 测试
- 提交
- 注册可以运行的任务及其依赖项。例如:
- Builder.RegisterTask( x => x.Clean )
- Builder.RegisterTask( x => x.Build ).DependsOn( x => x.Clean )
- Builder.RegisterTask( x => x.Test ).DependsOn( x => x.Build )
- Builder.RegisterTask( x => x.Commit ).DependsOn( x => x.Test )
- 运行构建器。例如 Builder.Execute()
测试任务
最终测试任务将调用 nunit、mstest、xunit 等,但首先构建所需的命令行。这是一个使用 .Net 而不是 PowerShell 对我来说更胜一筹的例子。
当我开发应用程序时,我遵循 ProjectName 和 ProjectName.Tests 的简单命名约定。构建系统搜索 *.Tests.dll 并将它们包含在 mstest 命令行中。
使用 .Net 应用程序构建此任务的优点是:
- 无需学习脚本语言来查找测试 dll。
- 使用我熟悉且功能丰富的 IDE 进行开发。
- 使用我熟悉且功能丰富的 IDE 调试任务。
总结
除了测试任务中列出的优点之外,BuildSolution 思想还有一个优点,即项目的新开发人员可以很容易地理解和编辑构建系统。
您认为 BuildSolution 的想法有哪些缺点?
Having just spent a frustrating amount of time configuring an automated build with psake the thought occurred to me why not use the language I know best to create a builder?
psake is an excellent framework to create an automated build. The trouble I always have is learning powershell to run more complex tasks. I'm sure the same can be said for NAnt, msbuild, etc.
My idea to solve this problem is create the build system for a given solution in .Net. The basic structure of the process would be this:
build.bat
rem // Set the environment for msbuild.
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\vcvars32.bat"
rem // Build the solution's builder.
msbuild.exe buildsolution.csproj
rem // Run the solution's builder.
BuildSolution.exe <task>
Project's BuildSolution
A tiny console application that:
- References the BuildSolution framework.
- Includes a method for each task. eg:
- Clean
- Build
- Test
- Commit
- Registers the tasks, and their dependencies, it can run. eg:
- Builder.RegisterTask( x => x.Clean )
- Builder.RegisterTask( x => x.Build ).DependsOn( x => x.Clean )
- Builder.RegisterTask( x => x.Test ).DependsOn( x => x.Build )
- Builder.RegisterTask( x => x.Commit ).DependsOn( x => x.Test )
- Runs the builder. eg Builder.Execute()
Test Task
Ultimately the test task will call nunit, mstest, xunit, etc but first builds the required command line. This is an example of where using .Net instead of PowerShell is a winner for me.
When I develop my applications I follow a simple naming convention of ProjectName and ProjectName.Tests. The build system searches for *.Tests.dll and includes them in the mstest command line.
The advantages of using a .Net application to construct this task is:
- No need to learn a scripting language to find test dlls.
- Develop with an IDE I know well and is feature rich.
- Debug the task with an IDE I know well and is feature rich.
Summary
In addition to the advantages listed in Test Task the BuildSolution idea has the advantage that it is arguably easy for new developers to the project to understand and edit the build system.
What cons do you see for the idea of BuildSolution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您正在谈论推出自己的解决方案。我会将其与使用其他人的现有解决方案进行比较。
优点:
。缺点:
最终你应该尝试添加你能想到的任何你自己的优点和缺点。尤其要考虑商业角度。两种解决方案的成本均以小时/美元为单位。从长远来看,使用成本较低的方法,或使用混合方法(一种是短期的,另一种是长期的,并制定迁移计划和时间表)。
话虽这么说,我已经在多个团队中解决过不止一种类型的问题。我也从使用自己的产品转向使用别人的产品。我发现它很有价值,并且我认为在某些情况下它可能是正确的解决方案,特别是如果您将其用作短期引导程序。
From what I can tell, you're talking about rolling your own solution. I will compare this to using someone else's existing solution.
Pros:
Cons:
Ultimately you should try to add any of your own pros and cons that you can think of. Especially consider the business standpoint. Cost both solutions in hours/dollars. Use whichever costs less in the long run, or use a hybrid approach (one in the short term, the other in the long term, and make a plan and schedule for migration).
That being said, I've rolled my own on more than one team, for more than one type of problem. I've also migrated from rolling my own to using someone else's product. I've found it to be valuable, and I think it can be the right solution in some situations, especially if you use it as a somewhat short term bootstrap.