問題描述
能否告訴 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的名稱的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!