MSBuild 根据调试/发布版本更改配置值

标签 msbuild

在我的 app.config 中,我有

<endpoint address="http://debug.example.com/Endpoint.asmx" stuff />

如何修改构建任务,以便在进行发布构建时将端点地址更改为

<endpoint address="http://live.example.com/Endpoint.asmx" stuff />

最佳答案

如果您的调试/发布配置分别命名为“调试”和“发布”,则应该这样做:

<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
  <endpoint address="http://debug.example.com/Endpoint.asmx" stuff />
  <!-- other things depending on Debug Configuration can go here -->
</PropertGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
  <endpoint address="http://live.example.com/Endpoint.asmx" stuff />
</PropertGroup>

关于MSBuild 根据调试/发布版本更改配置值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4712162/

相关文章:

c# - 在构建事件中所做的更改不会在 clickonce 发布时持续存在

.net - 在 MSBuild 中获取 "Reference Assemblies"路径

jenkins - msbuild 与命令行与 Jenkins 的行为不同

c# - Msbuild 使用唯一文件名复制和展平

c# - 分配从 MSBuild 中的属性获取的参数值

msbuild - TFS 2010 - 构建后部署到多个服务器

msbuild - VisualStudio.com 无法在构建期间加载临时 UWP 证书

msbuild - 如何解决 TFS 错误 TF237086 "The work item cannot be saved..."

tfs - 如何获得 .net 标准 2.0 项目以在 TFS2015 上构建

msbuild - 使用 msbuild v15.0 调试 msbuild 自定义任务