需要 Msbuild 新手的入门读物

发布于 2024-07-22 20:39:09 字数 403 浏览 3 评论 0原文

我们在工作中维护一个用 vb/c# .net 开发的中型 Windows 应用程序。 现在这个应用程序的构建和部署过程仍然是手动的。 我决心使用我现在还不了解的 MSBuild 使这个过程自动化。

我们的应用程序有一个简单的构建结构,一组项目已经分为四个解决方案(.sln),只需要按顺序构建四个 sln。 然后将项目(这是最后要构建的 sln 的一部分)发布到目录。 这就对了。 一个简单的过程已经消耗了 30 分钟的手动构建时间,我非常确定这可以在至少 1/4 的时间内使用 msbuild 来完成,而无需手动干扰。

我所有的目标都设定得很好,我开始在网络上寻找 MSBuild 资源来完成我的流程,但可能会发现很多事情让我困惑。 需要一个指针或一个关于如何开始以及从哪里开始我的简单场景的良好解释。 非常感谢您的帮助。

We maintain a medium sized windows application developed in vb/c# .net in work. Still now the build and deploy process for this app is manual. I am determined to make this process automated using MSBuild on which i have no knowledge still now.

Our app has a simple build structure, set of projects already grouped into four solutions(.sln) and just need to build the four slns in an order. And then publish a project(which is part of the last sln to be built) to a directory. That is it. A simple process which is already consuming 30 mins of manual build time and i'm pretty sure that this can be accomplished without manual interference using msbuild in atleast 1/4 th of the time.

All my goals set good, i started looking around web for MSBuild resources to accomplish my process but may be looking around many things confused me. Need a pointer or a good explanation on how to start and where to start for my simple scenario. Help is much appreciated.

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

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

发布评论

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

评论(2

心凉 2024-07-29 20:39:10

这听起来是一个非常容易编写的脚本。 即使是批处理文件也可以:

msbuild \path\to\first.sln /p:Configuration=Release
msbuild \path\to\second.sln /p:Configuration=Release
msbuild \path\to\third.sln /p:Configuration=Release
msbuild \path\to\fourth.sln /p:Configuration=Release
call deploy

当然,更好的是让服务器运行,例如 CruiseControl.NET,提供构建状态和历史记录的 Web 界面。

在 MS Build 中,调用者有两个主要控制点:目标及其属性。 Target 是要编译的内容、资源、编译、部署等。Properties 控制 Target 的构建方式。

您可以使用配置属性来控制配置(见上文)。 如果您打开 *.*proj 文件,您会注意到 PropertyGroup 元素。 这些可以通过命令行使用 /p 参数进行设置。

以下是两个参数的规格:

/target:<targets>  Build these targets in this project. Use a semicolon or a
                 comma to separate multiple targets, or specify each
                 target separately. (Short form: /t)
                 Example:
                   /target:Resources;Compile

/property:<n>=<v>  Set or override these project-level properties. <n> is
                 the property name, and <v> is the property value. Use a
                 semicolon or a comma to separate multiple properties, or
                 specify each property separately. (Short form: /p)
                 Example:
                   /property:WarningLevel=2;OutDir=bin\Debug\

This sounds like a very easy script to write. Even a batch file would do:

msbuild \path\to\first.sln /p:Configuration=Release
msbuild \path\to\second.sln /p:Configuration=Release
msbuild \path\to\third.sln /p:Configuration=Release
msbuild \path\to\fourth.sln /p:Configuration=Release
call deploy

Of course, much better would be to have a server running, say CruiseControl.NET, that gives a web interface into the build status and history.

In MS Build, there are two main control points for the caller: The Target and its Properties. The Target is what to compile, resources, compilation, deployment, etc. The Properties control how that Target is built.

You can control the configuration using the Configuration property (see above). If you open your *.*proj files, you will notice PropertyGroup elements. These are settable via the commandline using the /p arg.

Here are the specs for the two args:

/target:<targets>  Build these targets in this project. Use a semicolon or a
                 comma to separate multiple targets, or specify each
                 target separately. (Short form: /t)
                 Example:
                   /target:Resources;Compile

/property:<n>=<v>  Set or override these project-level properties. <n> is
                 the property name, and <v> is the property value. Use a
                 semicolon or a comma to separate multiple properties, or
                 specify each property separately. (Short form: /p)
                 Example:
                   /property:WarningLevel=2;OutDir=bin\Debug\
时间海 2024-07-29 20:39:10

这是一个很好的指南,其中包含有关 MSBuild、持续集成和 CuriseControl.NET 的大量重要信息。 绝对是一个很好的起点。

Here's a good guide that has a lot of great information on MSBuild, Continuous Integration and CuriseControl.NET. Definitely a good place to start.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文