Excluding and Including Files from Compiling for .NET in Microsoft Visual Studio

Limas Jaya Akeh
Bina Nusantara IT Division
2 min readSep 28, 2022

An incredibly brief explanation, in less than 2 minutes!

Photo by Habib Dadkhah on Unsplash

You’re developing something, and then, you hit “Compile”. Suddenly, there’s another file from your co-worker that is not working at all (or are conflicting with your file)! Well, maybe, you just want to ignore a certain file from compiling at all.

It’s as easy as one click — Just right click on the file you want to exclude from compiling.

Right-click Pop-up by Author

This will make sure that the file you’re excluding will not interrupt any other files, well except if you have dependency toward that file.

But wait! The file is now gone! What happened?

Solution Explorer by Author

Do not panic, at your Solution Explorer, just click “Show All Files”

Solution Explorer by Author

From the picture below, you can see that the file is still there, although invisible. You can include it back by clicking “Include in Project”.

Solution Explorer by Author

Anyway, if you’re wondering how do Visual Studio keeps track of which files to ignore, you can check the .csproj file.

Removed file from Compiling by Author

And you’re all set. That is sure very quick right?

--

--