[英]How to Add Build Properties / Macros in Visual Studio 2015 Community
I am building a UWP app and I see in the App.xaml.cs file the following line: 我正在构建UWP应用,并且在App.xaml.cs文件中看到以下行:
#if DEBUG
...
#endif
I am presuming this is a macro that is set somewhere and I would like to set my own / see what else is available, but I can't for the life of me find where this is located. 我想这是一个设置在某个地方的宏,我想设置自己的宏/看看还有什么可用,但是我一生无法找到它的位置。
If someone doesn't know the answer to this, but knows the best practice approach for changing something like an API key based on the build configuration, I would also accept that as an answer. 如果某人不知道此答案,但知道基于构建配置更改诸如API密钥之类的最佳实践方法,我也将其作为答案。
The conditional compilation symbols for a C# project are defined in the project properties. 在项目属性中定义了C#项目的条件编译符号。 To access the properties, right click on the project in the
Solution Explorer
, then select Properties
. 要访问属性,请在
Solution Explorer
右键单击项目,然后选择“ Properties
。 In the tab that opens, select Build
. 在打开的标签中,选择
Build
。 The conditional symbols can be configured from that page. 可以从该页面配置条件符号。
This screenshot is from Visual Studio 2013, but the layout hasn't really changed since Visual Studio 2008. 该屏幕截图来自Visual Studio 2013,但自Visual Studio 2008起,布局并没有真正改变。
The only pre-defined symbols are DEBUG
and TRACE
which can be turned on and off for various build configurations. 唯一预定义的符号是
DEBUG
和TRACE
,可以针对各种构建配置打开和关闭它们。 The Conditional compilation symbols
textbox provides a place to enter custom symbols. Conditional compilation symbols
文本框提供了一个输入自定义符号的位置。 Some compilation symbols are automatically added when a build configuration is created. 创建构建配置时,会自动添加一些编译符号。 In the screenshot above the defined constants are
TRACE
and WIN64
. 在上面的屏幕快照中,定义的常量为
TRACE
和WIN64
。
Further Reading: How to: Create and Edit Configurations 进一步阅读: 如何:创建和编辑配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.