我有一个经典的云服务项目,该项目在单个服务上有多个网站,在 ServiceDefinition.csdef
中配置如下:
<WebRole name="PE.Roles.API" vmsize="Small">
<Sites>
<Site name="API" physicalDirectory="..\..\..\PE.Roles.API">
<Bindings>
<Binding name="http" endpointName="PE.API" />
</Bindings>
</Site>
<Site name="PE.Services.Authorization" physicalDirectory="..\..\..\PE.Services.Authorization">
<Bindings>
<Binding name="http" endpointName="PE.Services.Authorization" />
</Bindings>
</Site>
<!-- Etc -->
</Sites>
</WebRole>
这可以在 Visual Studio 2015 中正确编译和打包,并且可以毫无问题地从预编译的 .cspkg
文件部署到云服务。
我们最近迁移到 Visual Studio Team Services for DevOps,我正在尝试使用提供的 Azure 云服务构建模板将此解决方案设置为在云中构建和部署。
.sln
构建步骤正确完成,但 .ccproj
构建步骤失败并出现以下错误:
PE.Azure\bin\ServiceDefinition.csdef (0, 0)
PE.Azure\bin\ServiceDefinition.csdef(0,0): Error CloudServices079: Cannot find the physical directory 'D:\a\1\PE.Roles.API' for virtual path API/.
Process 'msbuild.exe' exited with code '1'.
我的构建参数是:/t:Publish/p:TargetProfile=$(targetProfile)/p:DebugType=None/p:SkipInvalidConfigurations=true/p:OutputPath=bin\/p:PublishDir="$ (build.artifactstagingdirectory)\\"
我发现了许多涉及类似问题的博客文章和 SO 问题,但没有任何内容能够准确解决这个问题(过去几年也没有发布任何内容)。
更新
我已经为该项目创建了一个 TFVC 存储库并实现了映射步骤,如下所示:
我需要做什么才能使其正常工作?
最佳答案
您需要根据physicalDirectory的设置修改源映射。
引用此示例进行修改:
<Site name="API" physicalDirectory="..\..\..\WebGeneralDemo">
<Bindings>
<Binding name="http" endpointName="WebGeneralDemo" />
</Bindings>
</Site>
更新:
如果这些项目位于 git 存储库中,您可以将结构保留在存储库中,如下所示:
- repo 协议(protocol)
--AzureCloudService演示
---AzureCloudService演示
---WebRole1
--WebGeneral演示
如果结构不是这样,您可以使用 Copy file task 复制文件夹(包括文件)。
更新
就这个具体问题而言,Repo 的原始结构如下:
...其中 .ccproj
文件位于 PE.Azure
文件夹中,正在发布的站点位于 PE.Roles.API
文件夹。
编译器正在 $(build.sourcesDirectory)
上方的目录中查找站点内容(因此 D:\a\1\
),因此修复错误的正确复制文件任务是:
每个站点都需要一个复制文件任务,并且这些任务必须放置在“构建解决方案 ***.sln”步骤之后、“构建解决方案 ***.ccproj”步骤之前。
关于azure - 如何使用 Visual Studio Team Services 在单个服务上发布具有多个站点的 Azure 云服务项目?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42445918/