使用MSBuild.exe到"发布]一个ASP.NET MVC 4项目的CMD线 [英] Using MSBuild.exe to "Publish" a ASP.NET MVC 4 project with the cmd line

查看:689
本文介绍了使用MSBuild.exe到"发布]一个ASP.NET MVC 4项目的CMD线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个命令来对 MSBuild.exe ,只是需要一个MVC 4项目并将其发布到指定目录。

I'm looking for a command to run against the MSBuild.exe that just takes a MVC 4 project and publishes it to a given directory.

例如,

MSBuild <solution>/<project>.csproj -publish -output=c:/folder

这显然是不正确的语法。我想简化我的问题。

This is obviously incorrect syntax. I'm trying to simplify my question.

这个问题构建XML的会谈,但我不试图做那么多事情的细节。

This question talks of a build XML, but I'm not trying to do anything with that much detail.

我只是试图做一个部署。

I'm simply trying to do a deploy.

这个问题,有人说MSDeploy的。我可以看看成,但它是唯一的选择?我没有在服务器上安装网络部署的能力。在这种情况下,我真正需要做的是发布,并公布项目的内容发送到指定目录服务器/文件系统上。

Further down in that question, someone speaks of "MSDeploy". I can look into that, but is it the only option? I do not have the ability to install web deploy on the server. In which case, all I really need to do is "Publish" and send the contents of the published project to a given directory on the server/file-system.

有没有人有一个班轮我可以使用?

Does anyone have a one liner I can use?

我必须使用MSDeploy?

Do I have to use MSDeploy?

是否MSDeploy需要在服务器上安装网络部署?

Does MSDeploy require web deploy to be installed on the server?

不设置网络部署在服务器上需要设置一些端口,权限,并安装某些IIS插件?

Doesn't setting up web deploy on the server require setting up some ports, permissions, and installing some IIS add-ons?

我喜欢只执行简单的东西。

I'd love to just execute something simple.

推荐答案

在VS 2012(以及在的的Azure SDK 获得VS 2010),我们已经简化了命令行发布为Web项目。我们通过使用发布配置文件做到这一点。

In VS 2012 (as well as the publish updates available in the Azure SDK for VS 2010) we have simplified command line publishing for web projects. We have done that by using Publish Profiles.

在VS的web项目,你可以创建一个使用发布对话框发布配置文件。当您创建配置文件会自动保存在属性下的\\ PublishProfiles项目。您可以使用创建的配置文件从使用命令行命令行发布以下。

In VS for a web project you can create a publish profile using the publish dialog. When you create that profile it is automatically stored in your project under Properties\PublishProfiles. You can use the created profile to publish from the command line with a command line the following.

msbuild mysln.sln /p:DeployOnBuild=true /p:PublishProfile=<profile-name>

如果你想存储在其他位置的发布配置文件(.pubxml文件),你可以在路径PublishProfile通过。

If you want to store the publish profile (.pubxml file) in some other location you can pass in the path to the PublishProfile.

发布配置文件的MSBuild文件。如果您需要自定义发布过程中,您可以在.pubxml文件里这样做直接。

Publish profiles are MSBuild files. If you need to customize the publish process you can do so directly inside of the .pubxml file.

如果你的最终目标是在命令行的属性来传递。我建议以下。创建示例发布在VS简介检查的发布配置文件,以确定您需要通过在命令行什么的MSBuild属性。 FYI并非所有公布法支持命令行发布(即FTP / FPSE)。

If your end goal is to pass in properties from the command line. I would recommend the following. Create a sample publish profile in VS. Inspect that publish profile to determine what MSBuild properties you need to pass in on the command line. FYI not all publish method support command line publishing (i.e. FTP/FPSE).

仅供参考,如果你正在构建的.csproj / .vbproj而不是的.sln和你使用VS 2012,你也应该在传递 /p:VisualStudioVersion=11.0 。有关详细信息,为什么看<一个href=\"http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx\">http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.

FYI if you are building the .csproj/.vbproj instead of the .sln and you are using VS 2012 you should also pass in /p:VisualStudioVersion=11.0. For more details as to why see http://sedodream.com/2012/08/19/VisualStudioProjectCompatabilityAndVisualStudioVersion.aspx.

这篇关于使用MSBuild.exe到&QUOT;发布]一个ASP.NET MVC 4项目的CMD线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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