团队构建:使用 MSDeploy 本地发布
我刚刚开始使用团队构建功能,我发现做一些非常简单的事情所需的大量事情有点令人不知所措。我目前的设置是一个包含 Web 应用程序、组装应用程序和测试应用程序的解决方案。 Web 应用程序设置了一个通过文件系统发布的 PublishProfile。
我设置了一个 TFS 构建定义,当前每晚构建整个解决方案并将其作为旧构建的备份放到网络共享上。我现在想做的就是让我已经设置的 PublishProfile 为我发布 Web 应用程序。我确信这确实很简单,但我已经使用 MSBuild 命令一整天了,但没有运气。帮助!
I'm just getting started with the team build functionality and I'm finding the sheer amount of things required to do something pretty simple a bit overwhelming. My setup at the moment is a solution with a web app, an assembly app and a test app. The web app has a PublishProfile set up which publishes via the filesystem.
I have a TFS build definition set up which currently builds the entire solution nightly and drops it onto a network share as a backup of old builds. All I want to do now is have the PublishProfile I've already setup publish the web app for me. I'm sure this is really simple but I've been playing with MSBuild commands for a full day now with no luck. Help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,MSBuild 不支持或实现发布配置文件的共享。从配置文件发布的逻辑包含在 VS 本身中。幸运的是,该配置文件不包含太多信息,因此有多种方法可以实现您正在寻找的内容。我们的目标并不特别支持与发布对话框所遵循的完全相同的步骤,但为了从团队构建中获得相同的结果,您有两种选择,我将在此处概述这两种选择。
当您设置 Team Build 定义以进行部署时,您需要为构建过程的 MSBuild 参数传递一些值。请参见下图,我在其中突出显示了这一点。
选项 1:
传递以下参数:
让我稍微解释一下这些参数,向您展示结果,然后解释下一个选项。
DeployOnBuild=true
:这告诉项目执行DeployTarget
属性中定义的目标。DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder
:这指定 DeployTarget 目标。PackageTempRootDir="\\sayedha-w500\BuildDrops\Publish"
:指定写入包文件的位置。这是文件在打包之前写入的位置。AutoParameterizationWebConfigConnectionStrings=false
:这告诉 Web 发布管道 (WPP) 不要参数化 web.config 文件中的连接字符串。如果您不指定此项,那么您的连接字符串值将被替换为占位符,例如 $(ReplacableToken_dummyConStr-Web.config Connection String_0)执行此操作后,您可以启动构建,然后在 PackageTempRootDir 位置内您将找到一个 PackageTmp 文件夹和这包含您正在寻找的内容。
选项 2:
因此,对于前一个选项,您可能注意到它创建了一个名为 PackageTmp 的文件夹,如果您不希望这样做,则可以使用以下选项。
此处的区别在于,您将传入
_PackageTempDir
,而不是PackageTempRootDir
。我之所以不建议这样做,是因为以 _ 开头的 MSBuild 属性表示该属性本质上是“内部”的,在未来的版本中它可能意味着其他内容或根本不存在。因此,使用风险需您自担。选项 3
综上所述,您可以使用该构建来打包您的网站。如果您想这样做,请使用以下参数。
当您在构建的放置文件夹中执行此操作时,您将像平常一样找到 _PublishedWebsites 文件夹,然后在该文件夹内将有一个文件夹 {ProjectName}_Package,其中 {ProjectName} 是项目的名称。该文件夹将包含包、.cmd 文件、参数文件和其他几个文件。您可以使用这些文件来部署您的网络。
我希望这不是信息过载。
Unfortunately sharing of the Publish Profile is not supported or implemented in MSBuild. The logic to publish from the profile is contained in VS itself. Fortunately the profile doesn't contain much information so there are ways to achieve what you are looking for. Our targets do not specifically support the exact same steps as followed by the publish dialog, but to achieve the same result from team build you have two choices, I will outline both here.
When you setup your Team Build definition in order to deploy you need to pass in some values for the MSBuild Arguments for the build process. See image below where I have highlighted this.
Option 1:
Pass in the following arguments:
Let me explain these parameters a bit, show you the result then explain the next option.
DeployOnBuild=true
:This tells the project to execute the target(s) defined in theDeployTarget
property.DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder
: This specifies the DeployTarget target.PackageTempRootDir="\\sayedha-w500\BuildDrops\Publish"
: This specifies the location where the package files will be written. This is the location where the files are written before they are packaged.AutoParameterizationWebConfigConnectionStrings=false
: This tells the Web Publishing Pipeline (WPP) to not parameterize the connection strings in the web.config file. If you do not specify this then your connection string values will be replaced with placeholders like $(ReplacableToken_dummyConStr-Web.config Connection String_0)After you do this you can kick off a build then inside of the PackageTempRootDir location you will find a PackageTmp folder and this contains the content that you are looking for.
Option 2:
So for the previous option you probably noticed that it creates a folder named PackageTmp and if you do not want that then you can use the following options instead.
The difference here is that instead of
PackageTempRootDir
you would pass in_PackageTempDir
. The reason why I don't suggest that to begin with is because MSBuild properties that start with _ signify that the property in essentially "internal" in the sense that in a future version it may mean something else or not exist at all. So use at your own risk.Option 3
With all that said, you could just use the build to package your web. If you want to do this then use the following arguments.
When you do this in the drop folder for your build you will find the _PublishedWebsites folder as you normally would, then inside of that there will be a folder {ProjectName}_Package where {ProjectName} is the name of the project. This folder will contain the package, the .cmd file, the parameters file and a couple others. You can use these files to deploy your web.
I hope that wasn't information over load.
发布网站、配置 IIS 以及推送 DEV->QA->RELEASE 周期的架构更改的能力需要自定义配置来模仿发布或涉及 IIS 设置的自定义代码。
从 Visual Studio 2013.2 开始,Microsoft 添加了一个第三方产品,该产品通过 Windows 工作流程管理网站部署、配置更改和数据库部署,并且是从 TFS 构建自动部署的推荐解决方案。
更多信息可以在这里找到:
http://www.visualstudio。 com/en-us/explore/release-management-vs.aspx
The ability to publish web sites, configure IIS and push schema changes for the DEV->QA->RELEASE cycle has required either custom configuration to imitate publish or custom code where IIS settings are involved.
As of Visual Studio 2013.2 Microsoft has added a third party product that manages deployment of web sites, configuration changes and database deployment with windows workflow and would be the recommended solution for automating deployment from TFS build.
More information can be found here:
http://www.visualstudio.com/en-us/explore/release-management-vs.aspx
您可以在 Visual Studio 2010 中使用发布/部署。
请参阅 http://www.ewaldhofman.nl/post/2010/04/12/Auto-deployment-of-my-web- application-with-Team-Build-2010-to-add-Interactive-Testing.aspx 了解更多信息
You can use the Publish/Deploy in Visual Studio 2010.
See http://www.ewaldhofman.nl/post/2010/04/12/Auto-deployment-of-my-web-application-with-Team-Build-2010-to-add-Interactive-Testing.aspx for more information