A way to exlude files

I’m after a method to exclude files and folders inside a project from a build. Is there a way?