根据 VS2008 中的构建配置排除整个文件
我的项目有三种不同的配置,这三种配置不需要将所有文件构建到应用程序中。实际上,我更希望能够从构建中排除这些文件,这将使我的应用程序更加轻量级。
我正在寻找的是 #if MYCONFIG
或 #if DEBUG
语句,但适用于文件。我已经读到这可以通过手动编辑 csproj 文件来完成,但我找不到了......还有其他方法吗?
I have three different configurations on my project, all three do not require all files to be build into the application. Actually I'd prefer if I could exclude those files from the build, which would make my application a little more lightweight.
What I'm looking for is #if MYCONFIG
or #if DEBUG
statement but for files. I've already read that this can be accomplished by manually editing the csproj file, but I can't find that anymore...and are there other ways?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有两种不同的方式:
在您的 csproj 文件中,您将具有如下所示的部分:
您可以做的是设置一个新的项目配置(构建菜单,配置管理器,选择新建(来自活动解决方案配置下拉列表),然后手动将 ItemGroup 节点更改为:
正如您在问题中提到的,第二种方法是使用条件调试符号。在文件的顶部有语句
,在底部有
然后您可以定义调试符号;右键单击您的项目文件,选择“属性”,转到“构建”选项卡,然后在“条件编译符号”文本框中输入调试符号。
我可能会坚持第一种方法。
There are two different ways:
In your csproj files, you will have sections that look like this:
What you can do is set up a new project configuration (Build menu, Configuration Manager, select New from the Active solution configuration dropdown), then manually change the ItemGroup node to this:
The second way, as you referred to in your question, is to use conditional debug symbols. At the top of your file, have the statement
and at the bottom have
then you can define the debug symbols; right clickon your project file, select Properties, go to the Build tab, and enter the debug symbol in the Conditional compilation symbols textbox.
I would probably stick with the first method.