Visual Studio 2010 Changes for VC++ (part 1)

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:
      < ItemGroup >
        < ClInclude Include="MainFrm.h" / >
        < ClInclude Include="Resource.h" / >
        < ClInclude Include="stdafx.h" / >
        < ClInclude Include="targetver.h" / >
        < ClInclude Include="Wordpad2010.h" / >
        < ClInclude Include="Wordpad2010Doc.h" / >
        < ClInclude Include="Wordpad2010View.h" / >
      < /ItemGroup >
    
  • 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.
      < PropertyGroup Label="Globals" >
        < ProjectGuid >{1E7DC2AA-8CAC-44A8-98F6-DE69249AD30C}< /ProjectGuid >
        < RootNamespace >Wordpad2010< /RootNamespace >
        < Keyword >MFCProj< /Keyword >
      < /PropertyGroup >
    
  • 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.

  < PropertyGroup Label="Globals" >
    < ProjectGuid >{AB3D9231-F8B6-4EAD-A15B-C792977AB26E}< /ProjectGuid >
    < RootNamespace >MixedModeDemo< /RootNamespace >
    < TargetFrameworkVersion >v3.5< /TargetFrameworkVersion >
    < Keyword >MFCDLLProj< /Keyword >
  < /PropertyGroup >

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.

8 Replies to “Visual Studio 2010 Changes for VC++ (part 1)”

  1. 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.

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

  3. 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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.