Jump to content
  • Advertisement
mister345

[Visual Studio 2017] How to exclude some files from the build that I never touch?

Recommended Posts

Hi guys, so I have about 200 files isolated in their own folder [physics code] in my Visual Studio project that I never touch. They might as well be a separate library, I just keep em as source files in case I need to look at them or step through them, but I will never actually edit them, so there's no need to ever build them.

However, when I need to rebuild the entire solution because I changed the other files, all of these 200 files get rebuilt too and it takes a really long time.

If I click on their properties -> exclude from build, then rebuild, it's no good because then all the previous built objects get deleted automatically, so the build will fail.

So how do I make the built versions of the 200+ files in the physics directory stay where they are so I never have to rebuild them, but

do a normal rebuild for everything else? Any easy answers to this? The simpler the better, as I am a noob at Visual Studio settings. Thanks.

Share this post


Link to post
Share on other sites
Advertisement
44 minutes ago, mister345 said:

They might as well be a separate library

So why not putting them in a separate project (for example as a static library) inside the same solution? Then you can (i) exclude the complete project if you do not use it, (ii) rebuild the project only in case of changes to that project, or (iii) keep working with the most recent build objects.

Configuring C++ files separately is generally a bad idea. If your Visual Studio xml configuration files get very large, you will forget about these configurations, resulting in many hours spent on debugging and rebuilding. And like you said, if those files are part of your other code base, the build objects will be deleted (note that Visual Studio calls it an intermediate directory for a reason).

Edited by matt77hias

Share this post


Link to post
Share on other sites

Oh I see. Ive never used VS in that way so I dont know how. I always just make one project for one solution. Is it still possible to put them in a separate project in the same solution now that they are already dumped into the main project? How would I do so if you dont mind my asking? Also, if the physics files are in a separate project but my main project files include/ reference them will it still compile and run?

Share this post


Link to post
Share on other sites
2 hours ago, mister345 said:

Is it still possible to put them in a separate project in the same solution now that they are already dumped into the main project?

You remove these files from your main project and add them to the new project (just like you once did in the main project). Note that you need to remove the files only from the main project, not remove the files and delete them from disk (Visual Studio will give you 3 options upon delete, including the usual cancel).

Also note that the "directory structure" you see in your Solution Explorer does not need to match the actual directory structure in your file system. For example: you can organize your files into folders in Visual Studio, while having all these files in one actual directory, or vice versa.

2 hours ago, mister345 said:

Also, if the physics files are in a separate project but my main project files include/ reference them will it still compile and run?

Yes and no. It won't work out of the box after creating a new project. You basically need to do three things:

  1. Add the new project as a reference to your main project (see the "References" inside each project in your "Solution Explorer"). This will ensure that projects will be built in the right order (dependencies) and ensures that your .lib of your new project is linked correctly.
  2. Modify the "Include Directories" of your main project and add the path(s) to the header files of your new project.
  3. Modify the "Source Directories" of your main project and add the path(s) to the source files of your new project.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!