The new version of Visual Studio, called Visual Studio 2010 comes with a series of changes for Visual C++. This includes a new build system, new project system, multi-targeting, new IntelliSense, support in MFC for new controls, new additions to the C++ compiler (which were already approved for C++0x), new deployment model, and others. In this post I will talk about the new build system and multi-targeting.

In order to show the changes I will create two simple projects, one in Visual Studio 2008, called Wordpad 2008, and one in Visual Studio 2010, called Wordpad 2010. These would be simple MFC single document applications. The image bellow shows the two solutions opened in Solution Explorer.

As you can see both versions contain the same solutions file (only the suffix in the name differs). The next image shows the files on disk, in comparison for the two solutions.

MS-Build System

The first thing to notice (though it might not be the obvious) is that the project file extension was modified. In Visual Studio 2008 it is called .vcproj, but in Visual Studio 2010 is called .vcxproj. Not only the extension changed, but also the content of the file. This is because in Visual Studio 2010, Visual C++ build system was changed from VCBuild to MSBuild. This build engine was already used for the languages targeting the .NET framework.

MSBuild uses XML project files, and the most important elements of a project are:

  • Items: units of input into the build system, grouped into item collections, which can be used as parameters to the tasks, using the syntax @(ItemCollectionName). Examples of items from the Wordpad2010 project:
  • Properties: pairs of key/value used to configure the builds. The value of a property can be changed after it was defined. They can be referred in the project file using the syntax $(PropertyName). Examples of properties from the Wordpad2010 project.
  • Tasks: reusable units of executable code used to perform builds. Example of tasks can be compiling input files, linking, running external tools. Tasks can be reused in different projects.
  • Targets: represent groupings of tasks in a particular order and expose parts of the project file as entry points into the build system.

You can get a deeper overview on the MSBuild engine here.

Another thing to notice is the presence of a file called Wordpad2010.vcxproj.filters. This file defines the solution explorer tree with the files contained in the project. This used to be a part of the file project, but in Visual Studio 2010 it was moved into a separate file. The reason is to keep the project file only for the build, not for the organization of the project.

The user specific settings used to be stored in a file called ProjectName.vcproj.fullyqualifiedusername.user. Now there is a new file called ProjectName.vcxproj.user.

You can read more about these changes in MSDN.

Multi-targeting

Visual Studio 2008 came to support for multi-targeting of the .NET framework, not only for C# and VB.NET, but also for C++/CLI. In addition to that, Visual Studio 2010 comes with support for native multi-targeting.

The managed multi-targeting allows to target different versions of the .NET framework for mixed-mode applications. By default the target version is the latest, 4.0. This can only be changed manually in the project file. The support for changing this from the IDE was not included in this version. Actually it was dropped, because in Visual Studio 2008 this was possible.

The native multi-targeting allows to use different versions of the tools and libraries to build (native) C++ projects. Of course, you must have the targeted toolset installed on your machine, in order to do that. You can define different configurations that target different versions of the toolsets. The targeted toolset can be changed from project’s properties page, General, Platform Toolset. The following image shows the available options on a machine with Visual Studio 2008 SP1 and Visual Studio 2010 installed side by side.

It is possible to target the previous version, 2008, 2005, 2003 and 2002. In theory it’s possible to target even VC6, but there is no support from Microsoft for that.

I suggest to read more about native multi-targeting here, and about managed multi-targeting, for mixed-mode applications, here.

In a next post I will talk about the changes to IntelliSense and browsing experience.

, , Hits for this post: 60821 .
Trackback

8 comments untill now

  1. […] my previous post I talked about the new build system for VC++ from Visual Studio 2010, which is MSBuild and the […]

  2. […] MSBuild and multi-targeting Visual Studio 2010 changes for VC++ (part 1) […]

  3. Kurt Kennett @ 2010-10-20 06:15

    How do I set the default toolset that is selected when I create a project. I don’t want to have to change to the v7.1 toolset every time i create a project.

  4. […] Great series of posts about the new features in Visual Studio 2010 […]

  5. […] http://mariusbancila.ro/blog/2010/03/17/visual-studio-2010-changes-for-vc-part-1/ USEFUL? We decided to help other designers and engineers by opening up many of our companies internal notes and libraries through mini sites like this. We benefit hugely from resources on the web and feel we should give back some of our knowledge and resources to the community. If you find this site helpful all we ask in return is that you consider adding a link back to any page on this site somewhere on the web. Link ins massively help towards this site appearing in search engine results, allowing other engineers to find it more quickly and of course giving us a bit of that sweet Google juice! Thanks. LOGIN […]

  6. Phil Kinnamon @ 2011-03-03 22:27

    <
    Answer: I believe you can do this by creating a property sheet with this property set to the version you want.

  7. Shashank @ 2013-11-29 12:41

    Dear Mr. Marius Bancila,
    I have seen your blog related to visual studio, it has come out very well. It has lot of information related to .net which is helpful to developers like us.

    We recently developed a product called ‘Tremplin’. This tool will develop complete database application without involving you to write single line of code. I request you to write one article about our product and publish in your site. Since your site attracts lot of visitors, this will be of great help to us and intern we can offer one year free license to you.

    You can also take complete 30 minute course about this product at
    https://www.udemy.com/codeless-database-application-development-tremplin

    Please see this intro video http://www.youtube.com/watch?v=vrbJ0HzcLZI

    If you want more information you may visit http://www.erachana.net

    Thanks and Regards
    Shashank Kamath
    Customer Relationship Manager
    ERachana Software
    Email Id:Shashank.ess@gmail.com
    Mobile:+918147533797

Add your comment now