使用 Azure 辅助角色进行配置文件转换

发布于 2024-09-10 03:21:11 字数 650 浏览 0 评论 0 原文

我刚刚将 Azure 项目升级到 Visual Studio 2010,并利用了 VS2010 Web 项目中内置的新 XML 配置转换功能。它似乎与 Azure Web 角色配合得很好。我什至设法让 Azure 项目服务配置文件按照说明执行类似的操作 这里

但是,我似乎无法为我的 Azure 项目中的单独辅助角色进行配置转换。我知道 VS2010 仅内置对 Web 角色配置转换的支持,但我发现了 好文章 描述了如何在非 Web 项目中进行配置转换。我已按照说明进行操作,并且它有效 - 但仅限于一定程度。它成功地将正确的 .config 文件(经过适当的转换)吐出到辅助角色项目自己的 bin 目录中,但当将其放入云包中时,它不会选择这个新的 .config 文件。

我怀疑需要一些 MSBuild 技巧才能使其正常工作,但我不太了解 MSBuild,因此我向任何专家寻求帮助和/或示例:)

I've just been upgrading an Azure project to Visual Studio 2010 and have been taking advantage of the new XML configuration transformation feature that is built into VS2010 web projects. It seems to work great with Azure web roles. I even managed to get the Azure project service configuration file to do a similar thing by following the instructions here.

However, I can't seem to get configuration transformation working for the lone worker role in my Azure project. I know that VS2010 only has built-in support for config transformation with web roles, but I found a good article describing how to get config transformations working with non-web projects. I've followed the instructions and it works - but only to a point. It successfully spits out the correct .config file (with appropriate transformations) into the worker role project's own bin directory, but it doesn't pick this new .config file up when it's put into the cloud package.

I suspect there's some MSBuild trickery needed to get this to work, but I don't know MSBuild very well, so am appealing to any gurus out there for help and/or samples :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

高速公鹿 2024-09-17 03:21:11

我发现最好的方法是使用 msbuild。我通常在解决方案之外使用单独的 msbuild 文件来执行此操作,因此我将本地开发设置与生产设置分开。您可以了解更多信息 这里。然后,我可以运行构建来更改设置并将项目上传到 Azure。如果我需要调试问题,我还可以运行它来更改设置,然后通过 VS 运行部署。我在 msbuild 文件中还有一个目标,然后可以将所有内容恢复到本地。如果 VS 中有这些东西就好了(这是我向产品团队要求的)。示例项目位于 github 上。

我们编写的书中的生命周期章节也对此进行了解释。

I have found the best way to do this is to use msbuild. I usually do this with a separate msbuild file outside my solution so I keep the local dev settings separate from the production settings. You can find out more here. I then can run the build to change the settings and upload the project to Azure. I can also run this to change the settings and then run deploy through VS if I need to debug the problem. I also have a target in the msbuild file that then can revert everything back to local. It would be nice to have these things in VS (which I have asked for from the product team). The sample project is on github.

This is also explained in the book we wrote in the Life Cycle chapter.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文