简体   繁体   English

生成一个C#文件,但将其从项目中排除

[英]Build a C# file but exclude it from the project

I have a file that contains generated code which is rarely of interest when I search using Find In Files in the Current Project in Visual Studio. 我有一个包含生成代码的文件,当我在Visual Studio中的“当前项目”中使用“查找文件”进行搜索时,很少会对此感兴趣。 I'd like to have this file excluded from search, but still need it fully integrated into the project's build, including for output creation and IntelliSense. 我想将此文件排除在搜索范围之外,但仍需要将其完全集成到项目的构建中,包括用于输出创建和IntelliSense。

Moving the file to its own project so that it gets its own DLL would work. 将文件移到其自己的项目中,以便获得自己的DLL即可正常工作。 Is there a lighter weight approach that works within the existing project? 在现有项目中是否有更轻量级的方法可行?

Is there a lighter weight approach that works within the existing project? 在现有项目中是否有更轻量级的方法可行?

If I understand you correctly, one possible way I could think of is Look at these file types field present in Find and Replace (Shortcut: Ctrl + Shift + F). 如果我对您的理解正确,我想到的一种可能方法是查看“查找和替换”中的这些文件类型字段 (快捷方式:Ctrl + Shift + F)。 You could specify the file types with extensions or/and names. 您可以使用扩展名或/和名称指定文件类型。 You could use multiple names separated by a semicolon. 您可以使用以分号分隔的多个名称。 If there are other files of the same type of this file, this method will be ineffective. 如果存在与此文件相同类型的其他文件,则此方法无效。

Then you can try to use " Exclude From Project " option when you use Find In Files in the Current Project, after searching, click " Show All Files ", then select " Include In project ". 然后,当您在当前项目中使用“查找文件”时,可以尝试使用“ 从项目中排除 ”选项,搜索后,单击“ 显示所有文件 ”,然后选择“ 包含在项目中 ”。

在此处输入图片说明

在此处输入图片说明

Besides, you can vote for the feature in Visual Studio: Add "exclude files" to the "Look in" options under Find and Replace 此外,您可以在Visual Studio中对该功能进行投票: 在“查找和替换”下的“查找”选项中添加“排除文件”

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM