简体   繁体   中英

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:

#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.

The conditional compilation symbols for a C# project are defined in the project properties. To access the properties, right click on the project in the Solution Explorer , then select Properties . In the tab that opens, select 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.

属性页面的屏幕截图

The only pre-defined symbols are DEBUG and TRACE which can be turned on and off for various build configurations. The Conditional compilation symbols textbox provides a place to enter custom symbols. Some compilation symbols are automatically added when a build configuration is created. In the screenshot above the defined constants are TRACE and WIN64 .

Further Reading: How to: Create and Edit Configurations

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM