如何通过命令提示符调用 MSBuild? [英] How to invoke MSBuild via command prompt?

查看:36
本文介绍了如何通过命令提示符调用 MSBuild?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站(不是 Web 应用程序),我想每天晚上从同一目录中的命令提示符发布它.

I have a website (not a web application) and I want to publish it from the command prompt in the same directory every night.

我不想使用 TeamCity、TFS 等构建自动化工具或 Nant 等第三方工具 - 应该使用 MSBuild 来完成.我该怎么做?

I don't want to use build automation tools like TeamCity, TFS, or third-party tools like Nant - it should be done with MSBuild. How can I do this?

更新:在发布"窗口中,唯一应选中的选项是使用固定命名和单页程序集.

Update: in the Publish window the only option that should be checked is Use Fixed naming and single page assemblies.

推荐答案

根据您的评论,您的 Web 项目是一个网站项目,而不是一个 Web 应用程序项目.

From your comment, your web project is a web site project and not a web application project.

在这种情况下,发布"目标不能是选项,而AspNetCompiler"是解决方案.

In this case, 'Publish' target can not be the option but 'AspNetCompiler' is the solution.

创建一个包含以下内容的 xml 文件并从 MSBuild 中调用它.

Create an xml file with below content and call it from MSBuild.

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="PrecompileWeb">
        <AspNetCompiler
            VirtualPath="/MyWebSite"
            PhysicalPath="c:inetpubwwwrootMyWebSite"
            TargetPath="c:precompiledwebMyWebSite"
            Force="true"
            Debug="true"
            FixedNames="True"
        />
    </Target>
</Project>

此任务的参考是此处,您可以配置所有取消/选中选项.

Reference to this task is here and you can configure all your un/check options.

FixedName="True" 等同于勾选使用固定命名和单页..."选项.

FixedName="True" equals the checking of 'use fixed naming and single page...' option.

然后您从 MSBuild 调用此文件而不是解决方案文件.

Then you call this file from MSBuild instead of the solution file.

MSBuild your.xml /p:Configuration=<Debug/Release>

只要您的网站项目引用了您的类库,它们就会一起构建.

As long as your class libraries are referenced by your web site project, they'll be built together.

这篇关于如何通过命令提示符调用 MSBuild?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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