Search code examples
c++visual-studioinstallationnsispackaging

What cpp file types can I delete/exclude when packaging into an install bundle?


I want to package my executable file and other needed files into an install file (using NSIS) so that other people can install and use. There are a few file types I am uncertain of whether they are needed for installation or if it is safe to delete them.

Here is a random example of the files in the project folder as well as the Debug file automatically generated by VS:

Project FolderDebug Folder with Executable File

I have already deleted the .user file as I know that is not needed, but not sure when it comes to .vcxproj, .tlog, .build.cppclean, .idp, and .pdb files. Also, do I need to keep the .obj files as well as the .cpp files?

This is my first time trying to do this, I am just messing around to seeing how it all works so thanks in advance.


Solution

  • You generally only need the .exe. Your app might depend on custom .dlls or the C++ run-time library in which case you would bundle the custom .dlls and/or the C++ redistributable.

    Your screen shots are of a debug build and you normally want to distribute a release build instead because it is often smaller and contains more optimized code.

    .obj files contain the machine code for each source file and is used by the linker when it merges all the required code into your .exe.

    .pdb files contain debugging information. You should not distribute them but it is helpful to store them for yourself in case you need to debug a released version of your application.

    The rest of the files in Debug and Release can also be ignored.

    If your project is open source then you could include the c/c++ files and the Visual Studio project files. Or you could just upload them to Github.

    In NSIS you could do something like this

    InstallDir $ProgramFiles\MyApp
    Page Directory 
    Page InstFiles
    
    Section
    SetOutPath $InstDir
    File myproject\Release\MyApp.exe
    File mylibrary\Release\*.dll
    SectionEnd
    

    It is a good idea to test your installer on a freshly installed Windows instance. Ideally the minimal version you require, Windows 7 etc. This should allow you to verify that you have included all the files required by your application.