【发布时间】: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>
我也尝试过使用目标 AfterPackageComputeService、CopyWorkerRoleFiles 和 AfterAddRoleContent。所有结果都相同:1 个工作人员包含其配置转换,而另一个没有。
当我在本地运行时,两个工人 app.config 都被转换了。 我的猜测是,这两个 workerrole 的目标都是触发的,并且 WorkerTargetDir 变量始终设置为最后发布的 workerrole。
【问题讨论】:
-
您是否有单独的构建脚本或者您正在构建解决方案 .sln 文件?
-
我正在构建一个 .sln 文件。该脚本在我的云应用程序的 ccproj 文件中。
标签: azure configuration msbuild