简体   繁体   English

适用于Azure中多个辅助角色的App.config转换

[英]App.config transformations for multiple worker roles in Azure

I've got a Microsoft Azure solution that consists of: 我有一个Microsoft Azure解决方案,其中包括:

  • WorkerRole1 WorkerRole1
  • WorkerRole2 WorkerRole2
  • Webrole Webrole

I've applied configuration transformations to the app.config of both workerroles. 我已经将配置转换应用于两个workerroles的app.config。

Based on the answer of following question: Azure Worker Role Config File Transformations I am able to get 1 of the workers (Worker2) transformed app.config into the published package. 基于以下问题的答案: Azure工作者角色配置文件转换我能够将其中一个工作者(Worker2)转换后的app.config放入已发布的程序包中。 The solution doesn't work for both of the roles though. 但是,该解决方案不适用于两个角色。 Is there a way include both the workers transformed app.configs in the package? 有没有办法在软件包中包含两个工作人员转换的app.configs?

Here is my msbuild code: 这是我的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>

I've also tried using the targets AfterPackageComputeService , CopyWorkerRoleFiles and AfterAddRoleContent . 我也尝试过使用目标AfterPackageComputeServiceCopyWorkerRoleFilesAfterAddRoleContent All have the same result: 1 worker has its configuration transformations included and the other doesn't. 全部具有相同的结果:1个工作程序包含其配置转换,另一个不包含。

When I run locally both of the workers app.config are transformed. 当我在本地运行时,两个worker app.config都会发生转换。 My guess is that the target is fired ones for both the workerroles and that the WorkerTargetDir variable is always set to the last published workerrole. 我的猜测是,目标对象都同时为workerrol触发,并且WorkerTargetDir变量始终设置为上次发布的workerrole。

Try to use the same target changing your code in this way: 尝试使用相同的目标以这种方式更改代码:

<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" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM