【发布时间】:2014-10-25 20:06:50
【问题描述】:
我有一个包含以下项目的 Azure 云服务的 Visual Studio 解决方案:
- 云服务
- 云服务角色
- 测试
Tests 项目是一个标准的 MSTest 项目,其中包含CloudServiceRole 项目中业务逻辑的单元测试。
代码存储在 Visual Studio Online 中,我已经连接了 Azure 提供的自动化 CI 构建部署。当我签入代码时,我的云服务的暂存部署会自动更新。但是,在 CI 构建期间甚至从未构建过 Tests 项目!当然,这意味着在构建过程中不会运行任何单元测试,因为构建过程的“运行单元测试”部分找不到带有测试的程序集。
我的目标是改变这一点,以便构建测试项目并执行所有单元测试。
查看 CI 部署过程使用的 MSBuild 参数,似乎只执行了 CloudService:Publish 目标。 CloudService 项目不依赖于 Tests 项目,因此 MSBuild 甚至从不构建后者。
我的尝试
我无法手动添加 CloudService->Tests 依赖项,因为当我在不是云服务角色项目的项目上添加依赖项时,我在构建过程中遇到错误 (The item "C:\a\src\MyProject\Tests\Tests.csproj" in item list "ProjectReferenceWithConfiguration" does not define a value for metadata "Name".) 并且我无法添加 CloudServiceRole->Tests 依赖项,因为那样会做一个循环依赖。
通过手动添加/t:Build 参数来指示MSBuild 构建完整解决方案导致另一个错误:C:\a\bin\ServiceDefinition.csdef: Need to specify the physical directory for the virtual path 'Web/' of role Web.
将Tests 项目添加为单独的构建目标以及解决方案,会导致构建测试!但是,与此同时,它会禁用持续部署功能:More than one solution found. Continuous Deployment skipped.
尝试创建一个引用 Tests 项目但配置零实例的虚假云服务角色项目会导致构建错误:WAT100: The following roles 'Tests.FakeRole' have an instance count of 0. Instance count of 0 is not supported in deployments to Microsoft Azure。正在尝试禁用此验证results in a build error due to a defect in the Azure SDK。
【问题讨论】:
标签: azure msbuild azure-devops continuous-deployment azure-cloud-services