简体   繁体   English

如何在Visual Studio 2015社区中添加构建属性/宏

[英]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. 唯一预定义的符号是DEBUGTRACE ,可以针对各种构建配置打开和关闭它们。 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 . 在上面的屏幕快照中,定义的常量为TRACEWIN64

Further Reading: How to: Create and Edit Configurations 进一步阅读: 如何:创建和编辑配置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio 2015社区中通过代码添加新项目? - How to add a new item through code in visual studio 2015 community? Visual Studio Community 2015中任何版本的意外异常 - Unexpected exception on any build in Visual Studio Community 2015 Visual Studio 2015社区中“添加视图”对话框的区别 - Difference in Add View dialog box in Visual Studio 2015 Community 无法将文件添加到Visual Studio 2015(社区)更新3 / TFS - Cannot add files to Visual studio 2015 (Community) Update 3 / TFS 如何在Visual Studio社区2015中将Copy Local Property设置为true - How to Set the Copy Local Property to true in visual studio community 2015 如何为Visual Studio 2015社区安装EF电动工具 - how to install EF power tools for visual studio 2015 community 如何在Windows 7 SP1上安装Visual Studio 2015社区 - How install Visual Studio 2015 community on windows 7 SP1 如何在 Visual Studio 2015 社区中创建“基本页面” - How to create a “Basic Page” in Visual Studio 2015 community 如何为Visual Studio 2015 Community Edition使用Type.GetTypeFromProgID() - How to use Type.GetTypeFromProgID() for Visual Studio 2015 Community Edition 如何在Visual Studio 2015社区中创建本地数据库? - How to create a local database in Visual Studio 2015 Community?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM