使用 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

查看:15
本文介绍了使用 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=包/p:PackageAsSingleFile=true/p:SkipInvalidConfigurations=true/p:PackageLocation="$(build.stagingDirectory)"

构建步骤包括一个 Visual Studio 构建步骤、一个 Visual Studio 测试步骤(目前禁用以最大限度地降低复杂性)、一个索引源和发布符号步骤(我认为我真的不需要),最后是一个副本和发布构建工件步骤.

我能够使用此配置构建此解决方案.我可以看到构建结果、构建日志、构建详细信息等.当我查看创建的工件时,我会看到两个工件:drop"和build.sourceLabel" 如果我使用 Artifacts Explorer 浏览放置文件,我在这个 drop 文件中找到了我的所有项目,对于网络应用项目,我可以导航到 webapp1objQAPackagePackageTempin 文件夹并查看网络应用的所有 DLL 等.

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

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

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

解决方案

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

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

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

最后,我将我的 Copy and Publish Build Artifacts 任务更改为仅搜索***.zip".将 Copy Root 留空并运行您的构建.构建完成后,您将在 [ProjectName]/[Configuration]/projectName.zip 下的每个项目中获得一个 zip 文件.

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

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 webapp1objQAPackagePackageTempin 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天全站免登陆