根据条件编译符号更改exe名称 [英] Change name of exe depending on conditional compilation symbol

查看:101
本文介绍了根据条件编译符号更改exe名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您能否告诉Visual Studio根据是否设置了特定的条件编译符号来输出exe文件的不同名称?

Can you tell Visual Studio to output a different name of an exe file depending on if a specific conditional compilation symbol is set?

推荐答案

由于按照Fredrik的建议为Assemblyname标记定义条件似乎使Visual Studio显得怪异,因此您可以稍后在csproj文件中更改程序集名称.使用选择元素类似于if语句,因此使用一个名称如果满足条件,可以附加,如下所示.

Since defining a condition to the assemblyname tag as suggested by Fredrik seems to make Visual Studio cranky, you can change the assembly name later in the csproj file. Using the Choose element is kind of like an if statement, so a name can be appended if a condition is met, demonstrated below.

从条件属性中的实例DefineConstants中获取子字符串似乎是不可能的(根据 MSDN )带有普通香草MSBuild",但是使用/p:Tag=value(

Getting a substring out of for instance DefineConstants in a condition attribute does not seem possible (according to MSDN) with "plain vanilla MSBuild", but one can define their own build targets and set a property when compiling with a /p:Tag=value (MSBuild command line reference)

  ...
  <Tag>true</Tag>
</PropertyGroup>
<Choose>
  <When Condition=" '$(Tag)' == 'true' ">
    <PropertyGroup>
      <AssemblyName>$(AssemblyName).TagDefined</AssemblyName>
    </PropertyGroup>
  </When>
</Choose>
<ItemGroup>
...

这篇关于根据条件编译符号更改exe名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆