【问题标题】:App.config transformations for multiple worker roles in AzureAzure 中多个辅助角色的 App.config 转换
【发布时间】:2015-03-25 17:30:38
【问题描述】:

我有一个 Microsoft Azure 解决方案,其中包括:

  • WorkerRole1
  • WorkerRole2
  • Webrole

我已将配置转换应用于两个 workerroles 的 app.config。

基于以下问题的答案:Azure Worker Role Config File Transformations 我能够将 1 个工人 (Worker2) 转换为 app.config 到已发布的包中。 但是,该解决方案不适用于这两个角色。 有没有办法在包中包含两个工人转换的 app.configs?

这是我的 msbuild 代码:

  <Target Name="CopyWorkerRoleConfigurations1" AfterTargets="CollectWorkerRoleFiles" Condition="Exists('$(WorkerTargetDir)\Worker1.dll.config')">
    <Copy SourceFiles="$(WorkerTargetDir)\Worker1.dll.config" DestinationFolder="$(IntermediateOutputPath)Worker1" OverwriteReadOnlyFiles="true" />
  </Target>
  <Target Name="CopyWorkerRoleConfigurations2" AfterTargets="CollectWorkerRoleFiles" Condition="Exists('$(WorkerTargetDir)\Worker2.dll.config')">
    <Copy SourceFiles="$(WorkerTargetDir)\Worker2.dll.config" DestinationFolder="$(IntermediateOutputPath)Worker2" OverwriteReadOnlyFiles="true" />
  </Target>

我也尝试过使用目标 AfterPackageComputeServiceCopyWorkerRoleFilesAfterAddRoleContent。所有结果都相同:1 个工作人员包含其配置转换,而另一个没有。

当我在本地运行时,两个工人 app.config 都被转换了。 我的猜测是,这两个 workerrole 的目标都是触发的,并且 WorkerTargetDir 变量始终设置为最后发布的 workerrole。

【问题讨论】:

  • 您是否有单独的构建脚本或者您正在构建解决方案 .sln 文件?
  • 我正在构建一个 .sln 文件。该脚本在我的云应用程序的 ccproj 文件中。

标签: azure configuration msbuild


【解决方案1】:

尝试使用相同的目标以这种方式更改您的代码:

<Target Name="CopyWorkerRoleConfigurations1" AfterTargets="CollectWorkerRoleFiles" >
<Copy SourceFiles="$(WorkerTargetDir)\Worker1.dll.config" DestinationFolder="$(IntermediateOutputPath)Worker1" OverwriteReadOnlyFiles="true" />
<Copy SourceFiles="$(WorkerTargetDir)\Worker2.dll.config" DestinationFolder="$(IntermediateOutputPath)Worker2" OverwriteReadOnlyFiles="true" />

【讨论】:

  • 这应该被接受为答案,因为没有其他响应并且此解决方案完美运行
猜你喜欢
  • 2012-11-29
  • 1970-01-01
  • 1970-01-01
  • 2011-08-22
  • 2014-11-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多