Azure的持续部署多个项目 [英] Azure continuous deployment for multiple projects

查看:309
本文介绍了Azure的持续部署多个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个Azure的网站,并将其连接到Visual Studio Online和这种自动建立一个持续部署版本(按<一个href=\"https://azure.microsoft.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso/\"相对=nofollow>此页面)。

I have created an Azure Web Site and connected it to Visual Studio Online, and this automatically set up a continuous deployment build (as per this page).

最初,这个工作有一个项目的解决方案,但现在我已经添加了一个Web API项目作为后端。这个被命名为这样的,它是href=\"http://stackoverflow.com/a/22099969/1880663\">两个项目按字母顺序第一

Initially this worked for a solution with one project, but now I have added a Web API project as a back end. This is named such that it is the first of the two projects alphabetically, and so now it is the only project that gets built and deployed whenever files are checked in. Which leads to my question:

我敢肯定,这一定是一个相当简单的更改为构建模板或参数,或者正在使用的版本的发布配置文件。唯一的问题是我不知道:A)如何更改默认的那些设置 TfvcContinuousDeploymentTemplate.12.xaml 建立模板,B)如何修改发布配置文件这是在连续部署的构建使用。

I'm sure it must be a fairly simple change to either the build template or parameters, or the publish profiles that are being used by the build. The only problem is I don't know: A) how to change those settings in the default TfvcContinuousDeploymentTemplate.12.xaml build template, and B) how to modify the publish profiles that are used in the continuous deployment build.

我已经,从Visual Studio中,手动发布了两个项目,并得到了他们所遵循的这个答案。每个项目我右键点击,点击发布,然后选择微软Azure的Web应用程序发布目标而添加的发布配置文件到我的项目(​​在所有设置填充后),让我怎么要我手动部署它们。

I have already, from within Visual Studio, manually published the two projects and got them to deploy to the right locations by following the instructions in this answer. I right-clicked on each project, clicked publish, then selected the "Microsoft Azure Web Apps" publish target which (after filling in all the settings) added the publish profiles to my projects and allowed me to manually deploy them how I wanted.

不幸的是似乎有没有办法重新上传这些发布配置文件,使他们可以在CD版本中使用。我他们签入源代码控制,我只需要知道我怎么能得到CD版本来使用它们。我怎样才能做到这一点?

Unfortunately there seems to be no way to re-upload those publish profiles so that they can be used in the CD build. I've checked them into source control, I just need to know how I can get the CD build to make use of them. How can I do this?

推荐答案

通过<一看完href=\"https://azure.microsoft.com/en-us/documentation/articles/cloud-services-continuous-delivery-use-vso/\"相对=nofollow>在我的问题第一个环节一遍,我注意到,您可以编辑构建定义(或模板)以指向您要使用的发布配置:

After reading through the first link in my question again, I noticed that you can edit the build definition (or template) to point to the publish profile that you want to use:

路径部署设置:您.pubxml文件的路径为一个web应用程序,相对于回购的根文件夹。忽略云服务。

Path to Deployment Settings: The path to your .pubxml file for a web app, relative to the root folder of the repo. Ignored for cloud services.

不幸的是,这两个不工作,只允许你指定一个发布配置文件。 presumably,即使指定这个说法合作,构建仍然只按字母顺序部署第一个应用程序。

Unfortunately, this both doesn't work and only allows you to specify one publish profile file. Presumably, even if specifying this argument worked, the build would still only deploy the first app in alphabetical order.

这导致我这个问题,虽然回答,这表明在Azure / TFVC持续部署,通过使用简单的工作普通的网络部署参数的MSBuild。看着我的构建在Visual Studio Online的诊断日志证明了这是事实;这里有相关的参数:

This lead me to this question and answer though, which suggests that the Azure/TFVC continuous deployment works simply by using the ordinary Web Deploy arguments to MSBuild. Looking at the diagnostic logs of my build in Visual Studio Online proved this to be the case; here are the relevant arguments:

C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.exe /p:DeployOnBuild=true /p:CreatePackageOnPublish=true /p:DeployIisAppPath=mysitename

所以,根据这个问题,使用特定的发布配置你可以设置额外的必要参数的MSBuild构建定义中:

So, as per that question, to use a specific publish profile you can just set the additional necessary MSBuild arguments in the build definition:

在这里输入的形象描述

每个项目都需要有一个发布配置文件名为publishprofilename.pubxml,在这种情况下,签入到源控制。我发现用户名(这是您的网站名称与在它前面一个美元符号)是不需要的,但不幸的是需要密码字符串。如果不包含它,你得到一个错误,这样在build:

Each project needs to have a publish profile called "publishprofilename.pubxml", in this case, checked into source control. I found that the user name (which is your site name with a dollar sign in front of it) is not needed, but unfortunately the password string is required. If you don't include it you get an error like this in the build:

Web部署任务失败。 (连接到远程计算机
  使用Web管理服务([mysitename] .scm.azurewebsites.net),
  但不能授权。

Web deployment task failed. (Connected to the remote computer ("[mysitename].scm.azurewebsites.net") using the Web Management Service, but could not authorize.

被要求没有其他论据我,但它似乎并不理想,密码已被包括在内。默认的安装部署,而无需使用发布配置文件,必须与密码莫名其妙授权,但我不知道怎么办。

No other arguments were required for me, but it doesn't seem ideal that the password has to be included. The default deployment setup, without using publish profiles, must be authorising with that password somehow, but I don't know how.

所以使得这种变化我浏览到[mysitename] .azurewebsites.net,它似乎仍然只是在Web API项目正在部署之后。然而,去安慰该网站并输入 DIR D:\\家\\网站\\ wwwroot文件我可以看到,这两个项目实际上正在部署。这只是这两个项目被部署到网站的根目录下的 D:\\家\\网站\\ wwwroot文件。在 DeployIisAppPath 设置在每个发布配置不同,但这些价值被忽略了。这是因为 / P:DeployIisAppPath = mysitename 参数的MSBuild(上述)覆盖在发布配置任何的PropertyGroup 设置* .pubxml文件,如这博客文章。

So after making this change I navigated to [mysitename].azurewebsites.net, and it appeared that still only the Web API project was being deployed. However, by going to console for the site and entering dir D:\home\site\wwwroot I can see that both projects are actually being deployed. It's just that both projects are being deployed to the root of the site, at D:\home\site\wwwroot. The DeployIisAppPath settings are different in each publish profile, but these values are being ignored. This is because the /p:DeployIisAppPath=mysitename argument to MSBuild (mentioned above) overrides any PropertyGroup settings in publish profile *.pubxml files, as described in this blog post.

我发现是,天青/ TFVC的持续部署过程通过其在TfvcContinuousDeploymentTemplate.12.xaml建立模板的 InitializeContinuousDeployment 构建活动,之前立即 RunMSBuild 活动。这需要您在构建定义指定的MSBuild参数,并追加到它们部署到Azure中所需要的人。不幸的是,这主要是硬codeD,这意味着它总是指定为解决方案中的所有Web项目的单一部署路径。你不能每个Web应用程序部署到单独使用发布配置不同的位置。

What I have found is that the continuous deployment process for Azure/TFVC works by having an InitializeContinuousDeployment build activity in the TfvcContinuousDeploymentTemplate.12.xaml build template, immediately before the RunMSBuild activity. This takes the MSbuild arguments you specify in the build definition, and appends to them the ones needed to deploy to Azure. Unfortunately, this is mostly hard-coded, and that means it always specifies a single deployment path for all web projects in the solution. You can't deploy each web app to a different location using publish profiles alone.

所以有解决方法的选择是有点像 BeforeBuild 的MSBuild目标添加到每个项目,覆盖 DeployIisAppPath 。这样做的问题是,在发布配置指定的路径,并在发布向导看出,将不再是实际被用于部署的路径。

So one workaround option is to add something like a BeforeBuild MSBuild target to each project, to override the command line value of DeployIisAppPath. The problem with this is that the path specified in the publish profile, and seen in the publish wizard, will no longer be the path actually being used for deployment.

所以,我是稍微好了解决方案;它是什么,我们将在新西兰形容为huckery。

So the solution I went with is marginally better; it is what we would describe in New Zealand as "huckery".

基本上,我添加了一个的InvokeMethod 构建 InitializeContinuousDeployment RunMSBuild 活动。对于本次活动的参数如下:

Basically I added an InvokeMethod build activity between the InitializeContinuousDeployment and RunMSBuild activities. The arguments for this activity are as follows:

DisplayName:
Configure build for using publish profiles (removes DeployIisAppPath MSBuild parameter)

GenericTypeArguments:
System.String

MethodName:
SetValue

TargetObject:
AdvancedBuildSettings

Parameters:
Direction:      Type:       Value
In              String      "MSBuildArguments"
In              String      String.Join(" ", AdvancedBuildSettings.GetValue(Of String)("MSBuildArguments", String.Empty).Split(New String() {" "}, StringSplitOptions.RemoveEmptyEntries).Where(Function(s) Not s.StartsWith("/p:DeployIisAppPath=")))

这样做是将删除的MSBuild命令行参数列表完全 DeployIisAppPath 参数,所以,它并不能取代在发布配置这种相同的属性。取而代之的是与分裂乱搞并加入字符串,这将是稍微更好,如果你可以只追加 / P:DeployIisAppPath =到命令行,但是这只是将该属性设置为空字符串,你会得到一个错误:

What this does is removes the DeployIisAppPath argument from the MSBuild command line arguments list completely, so that it doesn't override this same property in the publish profiles. Instead of the messing around with splitting and joining the string, it would be slightly nicer if you could just append /p:DeployIisAppPath="" to the command line, but this just sets the property to an empty string and you get an error:

ConcatFullServiceUrlWithSiteName任务未给出了一个值
  所需参数SiteAppName

"ConcatFullServiceUrlWithSiteName" task was not given a value for the required parameter "SiteAppName"

所以,就像我说的,pretty huckery,但它是一个解决方案,让你有多个Web项目的持续部署与更改默认设置的最小量到Azure。

So like I said, pretty huckery, but it's a solution that allows you to have continuous deployment of multiple web projects to Azure with a minimal amount of changes to the default setup.

这篇关于Azure的持续部署多个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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