排除根据配置整个文件从建立在VS2008 [英] Exclude whole files based on configuration from build in VS2008

查看:215
本文介绍了排除根据配置整个文件从建立在VS2008的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的项目三种不同的配置,这三个并不需要所有的文件可用于构筑的应用程序。其实我想preFER如果我可以从构建,这将使我的应用程序多了几分轻巧排除这些文件。

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.

我正在寻找的是#如果MYCONFIG #如果DEBUG 语句,但对于文件。我已经读到这可以通过手动编辑的csproj文件来实现,但是我找不到了...以及是否有其他办法吗?

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?

推荐答案

有两种不同的方式: 在您的csproj文件,你将有如下几个部分:

There are two different ways: In your csproj files, you will have sections that look like this:

<ItemGroup>
    <Compile Include="Helper.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

你可以做的是建立一个新的项目配置(构建的菜单,配置管理器的,选择的的距离的活动解决方案配置的下拉列表),则ItemGroup节点手动改成这样:

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:

<ItemGroup Condition=" '$(Configuration)' == 'MyNewConfiguration' ">
    <Compile Include="Helper.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>

第二种方式,因为你提到你的问题,是使用的条件调试符号。在你的文件的顶部,有语句

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

#if MYDEBUGSYMBOL

和在底部有

#endif

,那么你可以定义调试符号;右clickon您的项目文件,选择的属性的,进入的构建的标签,在条件编译符号进入调试符号的文本框。

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.

这篇关于排除根据配置整个文件从建立在VS2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆