Is there a simple way to add a path, globally (i.e. for all users on a machine), to the set of include/library directories in Visual Studio?
What I am looking for is the ability to safely add an include/library path to Visual Studio for all projects (past and future). This would be the equivalent of the INCLUDE, LIB, and LIBPATH environment variables that seem to work for command-line builds, but for some reason are completely ignored when building through Visual Studio. It must be applied to all users on a machine.
What I am NOT looking for is changing the user-specific MSBuild property sheets, Microsoft.Cpp.Win32.user.props
, as this only adds the paths for a particular user on a particular machine. Though this seems to be the recommended way to accomplishing "global" settings, it cannot be applied in my use-case:
I am involved in teaching an introduction to programming for engineers class, with roughly 1000 students per year. We have a computer lab for them to work on weekly lab quizzes, but any per-user settings/documents are purposely cleared every time a student logs out (hence we cannot rely on the user-props). As part of the course, they need to work with a custom course library for interacting with a hardware unit (hence the need to add an include/lib path). Manually adding the paths for each project is beyond what we teach students, and would become tedious given that they will create several projects per week through the term.
What we have tried:
- installing the required headers/libraries to the Windows SDK paths.
This is definitely not ideal, and breaks whenever the Windows SDK is updated to a newer version - installing the required header/libraries to Visual Studio's
Auxiliary
path.
By examining the default VC++ Include Directories, it seems like VS2017 includes the pathC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\VS
in its searches for headers and libraries. According to the docs, the folder is supposed to be for tools that are not truly part of the compilation process. This is what we currently do, but it feels wrong, and the folder location has changed with past Visual Studio versions, so may change in the future (we were stuck with VS2012 for the last 5 years because of this). We would also have to re-install the library whenever we update Visual Studio in the lab.
What we could try:
- Adding the paths to the toolset default property sheets.
Again, this is recommended against in various forums in favour of using the user-props ones (e.g. here). The sheets themselves warn not to modify them, there's a fear they can be reset whenever the toolset is updated, and if a new toolset is installed while upgrading VS, we would have to re-modify the default sheets for that toolset. - Creating a project template with the desired settings.
We could create a template that students should choose when they create their new project through the New Project Wizard. The fear is that if students create a project with the wrong template (which will inevitably occur often with classes of such sizes), and begin their quiz tasks without the proper environment set, it will be a nightmare dealing with the issues that come up with our limited staff. Also, templates are VS version-specific (and placed in a version-specific folder), so we would have to re-install the template every time the visual studio version is changed.
The whole idea is to future-proof our workflow. What we want to do is incredibly simple: add a single header and a single library to the default search paths, and it should work with any version of Visual Studio installed on a machine. On any other system/IDE, this is a trivial task. Command-line MSBuild even supports it through Environment Variables. But for some reason, we cannot find a simple solution with Visual Studio.
Does anyone have a better idea?