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条回答
forever°为你锁心
2楼-- · 2019-01-07 13:09

Use ExcludeFoldersFromDeployment inside <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> tag, example:

<ExcludeFoldersFromDeployment>FolderToExclude</ExcludeFoldersFromDeployment>

For files, use:

<ExcludeFilesFromDeployment>File1.aspx;File2.aspx</ExcludeFilesFromDeployment>
查看更多
闹够了就滚
3楼-- · 2019-01-07 13:09

I'm quite sure that there should be a "Exclude from build" property on the folder, but I don't have my Visual Studio with me at the moment. At the very least there is such a property on files.

查看更多
爷的心禁止访问
4楼-- · 2019-01-07 13:11

In a website project type, you can set the files/folders attributes to "hidden" in Explorer to achieve the same effect.

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

You could set the Build Action (in the Properties Window) to None for the files you want excluded. You could also right-click on the folder and choose Exclude from Project.

查看更多
别忘想泡老子
6楼-- · 2019-01-07 13:15
  1. Select the files that you don't want to have compiled on the Solution Explorer.

  2. Right click and choose Options...

  3. Set the "Build Action" on the files to "None".

That should do the trick for you!

查看更多
劫难
7楼-- · 2019-01-07 13:20

Right click all the files, and select Properties. Now set Action to None. Revert to Compile when you fixed the code :)

查看更多
登录 后发表回答