Microsoft Visual C++ NuGet
|This article applies to the following versions|
|Any||2010 Any Edition|
|Any||2012 Any Edition|
|Any||2013 Any Edition|
This guide assumes you had already obtained the source code to wxWidgets. This guide can be completed in 3 easy steps.
This package does not include any template code. It is simply a helper for linking the project to wxWidgets, saving developers from spending time manually editing the project property pages. A more apt name for the package would be wxWidgetsHelper since the package does not check out or redistribute the wxWidgets library.
1. Install the NuGet Package Manager via the Visual Studio Extension Manager
The package manager may already be installed depending on your version/edition of Visual Studio. It can be installed from within Visual Studio, by searching for "NuGet" within Visual Studio's Extension Manager (Tools->Extensions and Updates...). Detailed instructions can be found here.
2. Install the wxWidgetsTemplate NuGet Package via the NuGet Package Manager
This step is is also done from within Visual Studio, and can be done in one of two ways:
- Either: Search for and install the wxWidgetsTemplate from within the Manage NuGet Packages pane (Tools->Library Package Manager->Manage NuGet Packages for Solution...):
- Or: Enter the command Install-Package wxWidgetsTemplate within the Package Manager Console (If hidden, select View->Other Windows->Package Manager Console):
There are many other C++ libraries available via NuGet (most NuGet packages are portable .NET libraries). To find the C++ ones such as boost search for the Native tag. Using NuGet packages to distribute libraries is useful!
If you use Source Code Management, commit <SolutionDir>/.nuget/packages.config, <SolutionDir>/packages/repositories.config, and <ProjectDir>/packages.config. These contain the links to the NuGet packages; do not version the packages themselves. Other developers opening the project will be notified of the missing dependencies, the dependencies will be downloaded after they press the "Update" button on the prompt. See for more information. In the event that any NuGet packages are updated by their authors, NuGet will pop up a notification (visually within the NuGet windows) that updates are available.
3. Customize the target wxWidgets library options
Open your project's properties (for any project that links to wxWidgets libraries). The options may either appear in Common Properties or Configuration Properties depending on your version of Visual Studio. Here is a brief description of each of the options:
- wxWidgets path should point to your working copy of the wxWidgets library. This field will be populated with $(WXWIN) if you had defined it.
- SHARED determines if your project dynamically links or statically links to wxWidgets.
- wxTOOLKIT_PREFIX see documentation on this elsewhere. If you're not using msw then change this so that the appropriate libraries will be linked to.
- wxMSVC_VERSION Safe to leave this blank, unless you intend to use multiple builds of wxWidgets with multiple versions of the MSVC compiler.
- Print MSBuild Variables during compile? Think of this as a verbosity flag. If you encounter problems turn this on, and inspect the Output pane of visual studio to diagnose the problem(s).
- Build wxWidgets library? Will check to see that wxWidgets is built and up to date before building your project. If the target wxWidgets build isn't built, it will build it for you. Turn this off to speed up compilation time (as it would skip the check). If modifications please push them here.
When you build your project, Visual Studio will automatically build wxWidgets, define the necessary preprocessor directives, and link to the appropriate libraries before building your code. If dynamically linking to wxWidgets, it will set up hard links to the *.dll's within the output folder.
The options you choose here will be stored in a *.user file. Do not version this file in SCM, these are the user's options.
The package will automatically create and use a precompiled header file exclusively for wxWidgets (See CreatePrecompiledHeaderFileProcess.cpp within the package for more information). Note that PCH wasn't designed to be modifiable as modifications would be removed if the NuGet package is updated. It is a shim to be honest, I suggest you use your own PCH if you want to optimize compilation time on your code as well. When using your own PCH such as stdafx.h you'll need to define that manually in the project property pages.