如何配置 MSBuild 以将保存的发布配置文件用于 WebDeploy? [英] How do I configure MSBuild to use a saved publishProfile for WebDeploy?

查看:42
本文介绍了如何配置 MSBuild 以将保存的发布配置文件用于 WebDeploy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Visual Studio 创建了发布配置文件.它将该信息保存到位于我的项目目录根目录下的 MyProject.Publish.xml.

I have used Visual Studio to create a publish profile. It saved that information to MyProject.Publish.xml, located in the root of my project directory.

我希望在我的 CI 服务器上执行的 MSBuild 任务使用该文件作为其基本设置.理想情况下,如果我可以通过命令行参数覆盖属性,那就太棒了.

I would like the MSBuild task that gets executed on my CI server to use that file as its base settings. Ideally, if I could override properties via command line parameters, that would rock.

这可能吗?如果是这样,语法是什么?

Is this possible? If so, what is the syntax?

例如,我正在寻找类似的东西:

For example, I'm looking for something like:

MSBuild MyProject.csproj /P:UsePublishProfile=True /P:UserName=deployUser /P:Password=MyPassword

推荐答案

很遗憾地告诉您,VS2010 使用的publish.xml 文件并非旨在以这种方式使用.事实上,它甚至不是为了与他人签入/共享而设计的.

I'm sorry to tell you that the publish.xml file which VS2010 uses was not designed to be used in this way. In fact it was not even designed to be checked-in/shared with others.

读取/写入这些文件的逻辑严格包含在 Visual Studio 中,不能通过 MSBuild 使用.因此,今天没有直接的方法来执行此操作.您必须在调用 msbuild.exe 时传递各个属性名称/值.您可以看到我在 Team Build: Publish local using MSDeploy 了解更多信息.

The logic for reading/writing those files are strictly contained inside Visual Studio and not available through MSBuild. So there is no straight forward way of doing this today. You have to pass in the individual property names/values when you call msbuild.exe. You can see a similar question that I answered at Team Build: Publish locally using MSDeploy for more info.

请注意,我们已经在即将发布的 Visual Studio 版本中解决了这个问题.您可以通过下载 VS 11 开发人员预览版来查看.现在,所有配置文件都保存到它们自己的文件中(在解决方案资源管理器的属性"节点中的发布配置文件"下).它们现在设计为可签入并与团队成员共享.这些文件现在是 MSBuild 文件,您可以根据需要自定义它们.为了从命令行发布,只需传递 DeployOnBuild=true 并将 PublishProfile 设置为配置文件的名称.例如:

Just so you know we have addressed this in the up coming version of Visual Studio. You can see if by downloading the VS 11 developer preview. Now all the profiles are saved into their own files (under the PublishProfiles in the Properties node in Solution Explorer). They are now designed to be checked in and shared with team members. These files are now MSBuild files and you can customize them if you wish. In order to publish from the command line just pass DeployOnBuild=true and set PublishProfile to the name of the profile. For example:

msbuild.exe MyProject.csproj /p:DeployOnBuild=true;PublishProfile=MyProfile

这篇关于如何配置 MSBuild 以将保存的发布配置文件用于 WebDeploy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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