根据条件编译符号更改exe的名称

Change name of exe depending on conditional compilation symbol(根据条件编译符号更改exe的名称)
本文介绍了根据条件编译符号更改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 文件中更改程序集名称.使用 Choose 元素 有点像 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) 带有plain vanilla MSBuild",但是可以定义自己的构建目标并在使用 /p:Tag=value(MSBuild 命令行参考)

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的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

DispatcherQueue null when trying to update Ui property in ViewModel(尝试更新ViewModel中的Ui属性时DispatcherQueue为空)
Drawing over all windows on multiple monitors(在多个监视器上绘制所有窗口)
Programmatically show the desktop(以编程方式显示桌面)
c# Generic Setlt;Tgt; implementation to access objects by type(按类型访问对象的C#泛型集实现)
InvalidOperationException When using Context Injection in ASP.Net Core(在ASP.NET核心中使用上下文注入时发生InvalidOperationException)
LINQ many-to-many relationship, how to write a correct WHERE clause?(LINQ多对多关系,如何写一个正确的WHERE子句?)