有几种方法可以做到这一点......更简单的方法是对 CCPROJ 文件进行一点“黑客攻击”:
1) 为每个与配置名称(Release/Debug/QA/UAT/etc)匹配的环境创建 CSDEF 文件的克隆:ServiceDefinition.Release.csdef、ServiceDefinition.Debug.csdef 等。
2) 使用记事本编辑器将这些文件手动添加到 CCPROJ 文件中
3) 定义一个 Pre-Build Event 命令,将 ServiceDefinition.$(ConfigurationName).csdef 复制到 ServiceDefintion.csdef
瞧,现在您的 ServiceDefintion 将适应您使用的任何配置。
如果您想更高级或查看更多详细信息,请查看此博客条目,它可以帮助您统一切换各种设置
http://www.paraleap.com/blog/post/Managing-environments-in-a-distributed-Azure-or-other-cloud-based-NET-solution.aspx
编辑:这是一个有效的配置。请注意,其他文件被包含为类型“无”而不是 ServiceDefinition 以避免多重定义错误。
<ItemGroup>
<ServiceConfiguration Include="ServiceConfiguration.Local.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Development 1.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Development 2.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Local Dev 1.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Local Dev 2.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.QA 1.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.QA 2.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Pre-Production 1.cscfg" />
<ServiceConfiguration Include="ServiceConfiguration.Production.cscfg" />
<ServiceDefinition Include="ServiceDefinition.csdef" />
<None Include="ServiceDefinition.Local.csdef" />
<None Include="ServiceDefinition.Development 1.csdef" />
<None Include="ServiceDefinition.Development 2.csdef" />
<None Include="ServiceDefinition.Local Dev 1.csdef" />
<None Include="ServiceDefinition.Local Dev 2.csdef" />
<None Include="ServiceDefinition.QA 1.csdef" />
<None Include="ServiceDefinition.QA 2.csdef" />
<None Include="ServiceDefinition.Pre-Production 1.csdef" />
<None Include="ServiceDefinition.Production.csdef" />
</ItemGroup>