How do I exclude unit test compilation during the building or packaging process?

Hello, my team is running into an issue where during our build process, in our TeamCity setup, unit tests are also being compiled. We currently keep our tests in organized plugins depending on what it’s testing, but if there were to be a compiler error for example within our unit tests, this compiler error will also appear in our build/packaging process. Is there a way that when I’m looking to create a build, all unit test modules are excluded and when I want to run automation tests they are included?