How to exclude files from Visual Studio compile?

2019-01-07 12:31发布

I'm in the process of refactoring a project. I've got an entire subfolder which is known to be broken. Is there any declarative way to exclude that folder from the compile temporarily while I test the refactoring thus far?

I realize I could delete the folder, but I'd like to do this through configuration if possible.

13条回答
狗以群分
2楼-- · 2019-01-07 13:21

In Rider, right click file in Navigation Bar, click Properties, change Build action to None.

查看更多
手持菜刀,她持情操
3楼-- · 2019-01-07 13:22

This is a method I have found for IIS Website Projects.

Set the "Hidden" attribute for the file/folder which you want to exclude from project, and then refresh the project in Solution Explorer. For example:

1. Open Windows Explorer.
2. Go to the physical folder of your website.
3. Right click the file/folder which you want to exclude, and then select "Properties".
4. Check the "Hidden" attribute.
5. Click the "Refresh" button in the Visual Studio Solution Explorer

Benson Yu

Microsoft Online Community Support

Quoted from: https://forums.asp.net/post/1997766.aspx

查看更多
【Aperson】
4楼-- · 2019-01-07 13:26

On Visual studio 2010 or later, you can achieve the functionality in two ways.

  1. Right click the file, select 'Exclude From Project'

  2. Right click the file, select 'Properties' --> select 'Configuration Properties' --> select 'General' --> choose 'Yes' from drop down menu for option 'Excluded From Build'

查看更多
狗以群分
5楼-- · 2019-01-07 13:28

In Visual Studio 2010 you need to right click the project in the Solution Explorer and choose Unload Project

查看更多
孤傲高冷的网名
6楼-- · 2019-01-07 13:32

If you have a lot of image files in a folder, so many that compilation is a painfully long task; you can rename the folder in IIS, giving the folder a .exclude extension.

e.g. C:\intetpub\wwwroot\yoursite\images change to C:\intetpub\wwwroot\yoursite\images.exclude

Then when you compile your app, the .exclude folder is excluded from compilation.

查看更多
Explosion°爆炸
7楼-- · 2019-01-07 13:33

In VS 2010, right-click on the CPP module, choose Properties.

Then click on Configuration Properties -> General, Exclude from Build = Yes.

"Exclude from Project" is no good, it disappears from the other Configurations as well.

查看更多
登录 后发表回答