While Nate's answer is pretty good already, I'm going to expand on it more specifically for Visual Studio 2010 as requested, and include information on compiling in the various optional components which requires external libraries.
If you are using headers only libraries, then all you need to do is to unarchive the boost download and set up the environment variables. The instruction below set the environment variables for Visual Studio only, and not across the system as a whole. Note you only have to do it once.
- Unarchive the latest version of boost (1.47.0 as of writing) into a directory of your choice (e.g.
C:\boost_1_47_0
).
- Create a new empty project in Visual Studio.
- Open the Property Manager and expand one of the configuration for the platform of your choice.
- Select & right click
Microsoft.Cpp.<Platform>.user
, and select Properties
to open the Property Page for edit.
- Select
VC++ Directories
on the left.
- Edit the
Include Directories
section to include the path to your boost source files.
- Repeat steps 3 - 6 for different platform of your choice if needed.
If you want to use the part of boost that require building, but none of the features that requires external dependencies, then building it is fairly simple.
- Unarchive the latest version of boost (1.47.0 as of writing) into a directory of your choice (e.g.
C:\boost_1_47_0
).
- Start the Visual Studio Command Prompt for the platform of your choice and navigate to where boost is.
- Run:
bootstrap.bat
to build b2.exe (previously named bjam).
Run b2:
- Win32:
b2 --toolset=msvc-10.0 --build-type=complete stage
;
- x64:
b2 --toolset=msvc-10.0 --build-type=complete architecture=x86 address-model=64 stage
Go for a walk / watch a movie or 2 / ....
- Go through steps 2 - 6 from the set of instruction above to set the environment variables.
- Edit the
Library Directories
section to include the path to your boost libraries output. (The default for the example and instructions above would be C:\boost_1_47_0\stage\lib
. Rename and move the directory first if you want to have x86 & x64 side by side (such as to <BOOST_PATH>\lib\x86
& <BOOST_PATH>\lib\x64
).
- Repeat steps 2 - 6 for different platform of your choice if needed.
If you want the optional components, then you have more work to do. These are:
- Boost.IOStreams Bzip2 filters
- Boost.IOStreams Zlib filters
- Boost.MPI
- Boost.Python
- Boost.Regex ICU support
Boost.IOStreams Bzip2 filters:
- Unarchive the latest version of bzip2 library (1.0.6 as of writing) source files into a directory of your choice (e.g.
C:\bzip2-1.0.6
).
- Follow the second set of instructions above to build boost, but add in the option
-sBZIP2_SOURCE="C:\bzip2-1.0.6"
when running b2 in step 5.
Boost.IOStreams Zlib filters
- Unarchive the latest version of zlib library (1.2.5 as of writing) source files into a directory of your choice (e.g.
C:\zlib-1.2.5
).
- Follow the second set of instructions above to build boost, but add in the option
-sZLIB_SOURCE="C:\zlib-1.2.5"
when running b2 in step 5.
Boost.MPI
- Install a MPI distribution such as Microsoft Compute Cluster Pack.
- Follow steps 1 - 3 from the second set of instructions above to build boost.
- Edit the file
project-config.jam
in the directory <BOOST_PATH>
that resulted from running bootstrap. Add in a line that read using mpi ;
(note the space before the ';').
- Follow the rest of the steps from the second set of instructions above to build boost. If auto-detection of the MPI installation fail, then you'll need to look for and modify the appropriate build file to look for MPI in the right place.
Boost.Python
- Install a Python distribution such as ActiveState's ActivePython. Make sure the Python installation is in your PATH.
To completely built the 32-bits version of the library requires 32-bits Python, and similarly for the 64-bits version. If you have multiple versions installed for such reason, you'll need to tell b2 where to find specific version and when to use which one. One way to do that would be to edit the file project-config.jam
in the directory <BOOST_PATH>
that resulted from running bootstrap. Add in the following two lines adjusting as appropriate for your Python installation paths & versions (note the space before the ';').
using python : 2.6 : C:\\Python\\Python26\\python ;
using python : 2.6 : C:\\Python\\Python26-x64\\python : : : <address-model>64 ;
Do note that such explicit Python specification currently cause MPI build to fail. So you'll need to do some separate building with and without specification to build everything if you're building MPI as well.
Follow the second set of instructions above to build boost.
Boost.Regex ICU support
- Unarchive the latest version of ICU4C library (4.8 as of writing) source file into a directory of your choice (e.g.
C:\icu4c-4_8
).
- Open the Visual Studio Solution in
<ICU_PATH>\source\allinone
.
- Build All for both debug & release configuration for the platform of your choice. There can be a problem building recent releases of ICU4C with Visual Studio 2010 when the output for both debug & release build are in the same directory (which is the default behaviour). A possible workaround is to do a Build All (of debug build say) and then do a Rebuild all in the 2nd configuration (e.g. release build).
- If building for x64, you'll need to be running x64 OS as there's post build steps that involves running some of the 64-bits application that it's building.
- Optionally remove the source directory when you're done.
- Follow the second set of instructions above to build boost, but add in the option
-sICU_PATH="C:\icu4c-4_8"
when running b2 in step 5.
Great question. I just posted a very detailed blog entry about this at Web Deployment Tool (MSDeploy) : Build Package including extra files or excluding specific files.
Here is the synopsis. After including files, I show how to exclude files as well.
Including Extra Files
Including extra files into the package is a bit harder but still no bigee if you are comfortable with MSBuild, and if you are not then read this. In order to do this we need to hook into the part of the process that collects the files for packaging. The target we need to extend is called CopyAllFilesToSingleFolder. This target has a dependency property, PipelinePreDeployCopyAllFilesToOneFolderDependsOn, that we can tap into and inject our own target. So we will create a target named CustomCollectFiles and inject that into the process. We achieve this with the following (remember after the import statement).
<PropertyGroup>
<CopyAllFilesToSingleFolderForPackageDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForPackageDependsOn);
</CopyAllFilesToSingleFolderForPackageDependsOn>
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
</PropertyGroup>
This will add our target to the process, now we need to define the target itself. Let’s assume that you have a folder named Extra Files that sits 1 level above your web project. You want to include all of those files. Here is the CustomCollectFiles target and we discuss after that.
<Target Name="CustomCollectFiles">
<ItemGroup>
<_CustomFiles Include="..\Extra Files\**\*" />
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
<DestinationRelativePath>Extra Files\%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</FilesForPackagingFromProject>
</ItemGroup>
</Target>
Here what I did was create the item _CustomFiles and in the Include attribute told it to pick up all the files in that folder and any folder underneath it. If by any chance you need to exclude something from that list, add an Exclude
attribute to _CustomFiles
.
Then I use this item to populate the FilesForPackagingFromProject item. This is the item that MSDeploy actually uses to add extra files. Also notice that I declared the metadata DestinationRelativePath value. This will determine the relative path that it will be placed in the package. I used the statement Extra Files%(RecursiveDir)%(Filename)%(Extension) here. What that is saying is to place it in the same relative location in the package as it is under the Extra Files folder.
Excluding files
If you open the project file of a web application created with VS 2010 towards the bottom of it you will find a line with.
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
BTW you can open the project file inside of VS. Right click on the project pick Unload Project. Then right click on the unloaded project and select Edit Project.
This statement will include all the targets and tasks that we need. Most of our customizations should be after that import, if you are not sure put if after! So if you have files to exclude there is an item name, ExcludeFromPackageFiles, that can be used to do so. For example let’s say that you have file named Sample.Debug.xml which included in your web application but you want that file to be excluded from the created packages. You can place the snippet below after that import statement.
<ItemGroup>
<ExcludeFromPackageFiles Include="Sample.Debug.xml">
<FromTarget>Project</FromTarget>
</ExcludeFromPackageFiles>
</ItemGroup>
By declaring populating this item, the files will automatically be excluded. Note the usage of the FromTarget
metadata here. I will not get into that here, but you should know to always specify that.
Best Answer
None of these answers are sufficient in my mind. This does seem to be a genuine bug. I will update this response if I ever find a non-hack solution, or Microsoft fixes the bug.
Update:
Doesn't seem promising. https://connect.microsoft.com/VisualStudio/feedback/details/731303/publish-web-feature-not-including-all-dlls