Team Build:使用 MSDeploy 在本地发布 [英] Team Build: Publish locally using MSDeploy

查看:20
本文介绍了Team Build:使用 MSDeploy 在本地发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用团队构建功能,我发现做一些非常简单的事情所需的大量事情有点让人不知所措.我目前的设置是一个包含 Web 应用程序、程序集应用程序和测试应用程序的解决方案.Web 应用程序设置了 PublishProfile,通过文件系统进行发布.

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.

我有一个 TFS 构建定义设置,它目前每晚构建整个解决方案,并将其作为旧构建的备份放到网络共享上.我现在想要做的就是让我已经设置的 PublishProfile 为我发布网络应用程序.我敢肯定这真的很简单,但我已经玩了一整天的 MSBuild 命令,但没有运气.帮助!

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!

推荐答案

遗憾的是,MSBuild 不支持或实现发布配置文件的共享.从配置文件发布的逻辑包含在 VS 本身中.幸运的是,配置文件不包含太多信息,因此有多种方法可以实现您的需求.我们的目标并不特别支持与发布对话框完全相同的步骤,但要从团队构建中获得相同的结果,您有两种选择,我将在此处概述.

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.

当您设置 Team Build 定义以进行部署时,您需要为构建过程的 MSBuild 参数传递一些值.请参阅下图,其中我已突出显示了这一点.

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.

选项 1:传入以下参数:

/p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;PackageTempRootDir="\sayedha-w500BuildDropsPublish";AutoParameterizationWebConfigConnectionStrings=false

让我解释一下这些参数,向您展示结果,然后解释下一个选项.DeployOnBuild=true:这告诉项目执行在 DeployTarget 属性中定义的目标.

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 the DeployTarget property.

DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder:这指定了 DeployTarget 目标.

DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder: This specifies the DeployTarget target.

PackageTempRootDir="\sayedha-w500BuildDropsPublish":这指定将写入包文件的位置.这是文件在打包前写入的位置.

PackageTempRootDir="\sayedha-w500BuildDropsPublish": 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:这告诉 Web 发布管道 (WPP) 不要参数化 web.config 文件中的连接字符串.如果您不指定此项,则您的连接字符串值将被替换为诸如 $(ReplacableToken_dummyConStr-Web.config Connection String_0) 之类的占位符

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)

执行此操作后,您可以开始构建,然后在 PackageTempRootDir 位置内,您将找到一个 PackageTmp 文件夹,其中包含您要查找的内容.

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.

选项 2:因此,对于上一个选项,您可能注意到它创建了一个名为 PackageTmp 的文件夹,如果您不想要它,那么您可以改用以下选项.

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.

/p:DeployOnBuild=true;DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;_PackageTempDir="\sayedha-w500BuildDropsPublish";AutoParameterizationWebConfigConnectionStrings=false

这里的区别在于,您将传入 _PackageTempDir 而不是 PackageTempRootDir.我之所以不建议首先这样做是因为以 _ 开头的 MSBuild 属性表示该属性本质上是内部"的,因为在未来的版本中它可能意味着其他东西或根本不存在.因此使用风险自负.

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.

选项 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.

/p:DeployOnBuild=true;DeployTarget=Package

当您在构建的放置文件夹中执行此操作时,您会像往常一样找到 _PublishedWebsites 文件夹,然后在其中会有一个文件夹 {ProjectName}_Package,其中 {ProjectName} 是项目的名称.该文件夹将包含包、.cmd 文件、参数文件和其他一些文件.您可以使用这些文件来部署您的网络.

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.

这篇关于Team Build:使用 MSDeploy 在本地发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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