Reputation: 1732
I've got a Microsoft Azure solution that consists of:
I've applied configuration transformations to the app.config of both workerroles.
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. 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?
Here is my msbuild code:
<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. All have the same result: 1 worker has its configuration transformations included and the other doesn't.
When I run locally both of the workers app.config are transformed. 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.
Upvotes: 1
Views: 209
Reputation: 119
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" />
Upvotes: 1