使用Visual Studio团队服务构建包含多个Web应用程序的解决方案并将这些Web应用程序部署到Azure [英] using visual studio team services to build a solution containing multiple web apps and deploy these web apps to azure

查看:89
本文介绍了使用Visual Studio团队服务构建包含多个Web应用程序的解决方案并将这些Web应用程序部署到Azure的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队使用Visual Studio Team Services在TFS存储库中管理我们的源代码.该解决方案包含多个Web应用程序.我正在尝试为此解决方案配置持续集成和持续部署,以便在成功构建之后将每个Web应用程序部署到正确的Azure Web应用程序.我已经配置了BuildDefinition来构建$/MyProduct/MAIN/MySolution.sln.我根据在该主题上发现的一些MSDN文章,为MSBuild定义了以下参数:

/p:DeployOnBuild=true
/p:WebPublishMethod=Package
/p:PackageAsSingleFile=true
/p:SkipInvalidConfigurations=true
/p:PackageLocation="$(build.stagingDirectory)" 

构建步骤包括Visual Studio构建步骤,Visual Studio测试步骤(当前已禁用以最小化复杂性),索引源和发布符号步骤(我认为我并不需要),最后是复制并发布Build Artifacts步骤.

我能够使用此配置构建此解决方案.我可以看到生成结果,生成日志,生成详细信息等.当我查看创建的工件时,会看到两个工件:"drop"和"build.sourceLabel". ,我在此放置文件中找到了所有项目,对于Web应用程序项目,我可以导航到webapp1 \ obj \ QA \ Package \ PackageTemp \ bin文件夹中,并查看该Web应用程序的所有DLL等.

我看不到每个Web应用程序有一个zip文件,这正是Visual Studio Team Services的发布功能所期望的.

我想知道如何修改当前配置,以便可以从构建"步骤生成正确的工件,从而可以创建正确的Release Wep App Deployment任务,以将每个Web应用程序部署到我的正确Web应用程序中环境.

这一切都通过Visual Studio 2015和Visual Studio Online(团队服务)完成.

解决方案

为了测试您的情况,我使用Visual Studio 2015,并在同一解决方案中创建了3个新的Web项目,并签入VSTS.然后,我使用Azure网站部署模板创建了一个新版本.许多人想念我们在创建新的构建定义"对话框上有构建和部署"模板.我使用Azure网站模板的原因是因为我永远都不记得要传递的msbuild参数.如果要使用RM,则可以删除Azure Web App部署任务.

我始终对msbuild参数进行的一项更改是PackageLocation.我总是将我的更改为$(BuildConfiguration).这样,我可以同时构建Debug和Release.

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(BuildConfiguration)"

最后,我将复制和发布构建工件"任务更改为仅搜索"** \ *.zip".将复制根目录"保留为空,然后运行您的构建. 构建完成后,在探索工件时,每个项目的[ProjectName]/[Configuration]/projectName.zip下将有一个zip.

如果您还有其他问题,可以在Twitter @DonovanBrown

上ping我.

My team uses Visual Studio Team Services to manage our source code in a TFS repository. The solution contains multiple web apps. I am trying to configure Continuous Integration and Continuous Deployment for this solution such that each web application is deployed to the correct Azure web app after a successful build. I've configured the BuildDefinition to build $/MyProduct/MAIN/MySolution.sln. I've defined the following parameters to MSBuild based on some MSDN articles I found on this subject:

/p:DeployOnBuild=true
/p:WebPublishMethod=Package
/p:PackageAsSingleFile=true
/p:SkipInvalidConfigurations=true
/p:PackageLocation="$(build.stagingDirectory)" 

The build steps include a Visual Studio Build step, a Visual Studio Test step (currently disabled to minimize complexity), an Index Sources and Publish Symbols step (which I don't think I really need), and finally, a Copy and Publish Build Artifacts step.

I am able to build this solution using this configuration. I can see the build results, the build log, build details, etc. When I look at the artifacts that are created, I see two artifacts: "drop" and "build.sourceLabel" If I explore the drop file using the Artifacts Explorer, I find all of my projects in this drop file, and for the web app projects, I can navigate into the webapp1\obj\QA\Package\PackageTemp\bin folder and see all the DLL's etc. for the web app.

What I don't see is one zip file per web app, which is what the Release feature of Visual Studio Team Services is expecting.

I would like to know how to modify my current configuration so that I can generate the correct artifacts from the Build step so that I can create the correct Release Wep App Deployment tasks to deploy each web app to the correct web app in my environment.

This is all being done with Visual Studio 2015 and Visual Studio Online (Team Services).

解决方案

To test your situation I used Visual Studio 2015 and created 3 new web projects in the same solution and checked into VSTS. I then created a new build using the Azure Website deployment template. Many people miss that we have Build and Deployment templates on the Create New Build Definition dialog. The reason I use the Azure Website template is because I can never remember the msbuild arguments to pass in. You can simply delete the Azure Web App Deployment task if you are going to use RM.

One change I always make to the msbuild arguments is the PackageLocation. I always change mine to $(BuildConfiguration). That way I can build both Debug and Release at the same time should I desire.

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(BuildConfiguration)"

Finally I change my Copy and Publish Build Artifacts task to search for just "**\*.zip". Leave the Copy Root empty and run your build. When your build completes you will have one zip per project under the [ProjectName]/[Configuration]/projectName.zip when you explore your artifacts.

If you have further questions you can ping me on Twitter @DonovanBrown

这篇关于使用Visual Studio团队服务构建包含多个Web应用程序的解决方案并将这些Web应用程序部署到Azure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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