使用 MSBuild.exe “发布"带有 cmd 行的 ASP.NET MVC 4 项目 [英] Using MSBuild.exe to "Publish" a ASP.NET MVC 4 project with the cmd line

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

问题描述

我正在寻找一个针对 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.

我只是想进行部署.

那个问题中,有人谈到MSDeploy".我可以调查一下,但这是唯一的选择吗?我没有能力在服务器上安装 web deploy.在这种情况下,我真正需要做的就是发布"并将已发布项目的内容发送到服务器/文件系统上的给定目录.

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 是否需要在服务器上安装 Web 部署?

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

在服务器上设置 web deploy 不需要设置一些端口、权限和安装一些 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 for VS 2010) 我们为 Web 项目简化了命令行发布.我们通过使用 Publish Profiles 做到了这一点.

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 中,您可以使用发布对话框创建发布配置文件.当您创建该配置文件时,它会自动存储在您的项目中 PropertiesPublishProfiles 下.您可以使用创建的配置文件从命令行发布以下内容.

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 PropertiesPublishProfiles. 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 属性.仅供参考,并非所有发布方法都支持命令行发布(即 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.有关原因的更多详细信息,请参阅 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 “发布"带有 cmd 行的 ASP.NET MVC 4 项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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