首页 文章

如何使用Visual Studio Team Services在单个服务上发布包含多个站点的Azure Cloud 服务项目?

提问于
浏览
0

我有一个经典的 Cloud 服务项目,在单个服务上有多个网站,在_2722611中配置如下:

<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 文件到Cloud Service无故障地部署 .

我们最近转移到DevOps的Visual Studio Team Services,我正在尝试使用提供的Azure Cloud 服务构建模板将此解决方案设置为在 Cloud 中构建和部署 .

.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问题,涵盖了类似的问题,但没有任何解决这个问题(过去几年没有发布) .

Update

我已经为项目创建了一个TFVC repo并实现了映射步骤,如下所示:

enter image description here

...但我仍然得到同样的错误:
enter image description here

为了让这个工作,我需要做什么?

1 回答

  • 2

    您需要根据physicalDirectory的设置修改源映射 .

    请参考此示例进行修改:

    <Site name="API" physicalDirectory="..\..\..\WebGeneralDemo">
            <Bindings>
              <Binding name="http" endpointName="WebGeneralDemo" />
            </Bindings>
          </Site>
    

    enter image description here

    更新:

    如果这些项目位于git存储库中,您可以将结构保存在存储库中,如下所示:

    -Repo

    --AzureCloudServiceDemo

    --- AzureCloudServiceDemo

    --- WebRole1

    --WebGeneralDemo

    如果结构不是这样,您可以使用Copy file task复制文件夹(包含文件)

    Update

    就这个具体问题而言,回购的原始结构如下:

    enter image description here

    ... .ccproj 文件位于 PE.Azure 文件夹中,正在发布的站点位于 PE.Roles.API 文件夹中 .

    编译器正在 $(build.sourcesDirectory) 上面的目录中查找站点内容(所以 D:\a\1\ ),因此修复错误的正确复制文件任务是:
    enter image description here

    每个站点都需要一个“复制文件”任务,并且必须在构建解决方案*** . sln步骤之后,但在构建解决方案*** . ccproj步骤之前定位任务 .

相关问题