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

查看:119
本文介绍了如何通过命令提示符调用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?

更新:在发布"窗口中,唯一应选中的选项是Use Fixed naming and single page assemblies.

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:\inetpub\wwwroot\MyWebSite\"
            TargetPath="c:\precompiledweb\MyWebSite\"
            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天全站免登陆