10

Background

I am open sourcing a few old Visual Studio applications I created a while back. I have created new solutions using my new VS2012 environment for them and have gotten the projects set up as git repositories. I got everything working fine in Visual Studio 2012 with no changes to the source code, all I needed to do was make sure I was linking the proper libraries in the new project configurations.

I would like to configure these projects as to have maximum compatibility for others downloading the project from Github. On this machine I have VS2010 installed alongside the latest VS2012 version. After I got everything working right for both of the projects in VS2012, I tried to open them up in VS2010.

When I tried to build I got a single error:

Specified platform toolset (v110) is not installed or invalid.
Please make sure that a supported PlatformToolset value is selected.    
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets  518

What I Tried

So I opened up the properties for the project, went to Configuration Options --> General and the Platform Toolset was indeed set to Visual Studio 2012 (v110). This input is a drop down box and the v110 value is not listed, instead I get two choices:

  • v100
  • v90

These correspond to VS2010 and VS2008 respectively. If I change the value to v100 and rebuild I get no errors and my program runs just fine in my Visual Studio 2010 environment.

When I open the project back up in Visual Studio 2012, if tells me that I have an old project file and asks if I want to upgrade, I say yes and it upgrades. I rebuild and run to make sure everything is still working. When I open the configuration options in VS2012 the Platform Toolset is set back to `Visual Studio 2012 (v110) but clicking the drop down input there are several more choices listed:

  • Visual Studio 2012 (v110)
  • v110_wp80
  • Visual Studio 2012 - Windows XP (v110_xp)
  • Visual Studio 2010 (v100)
  • Visual Studio 2008 (v90)
  • ‹inherit from parent or project defaults›</li>

My Questions

This has led me to several questions. I am going to pose them all. It would be nice to get as much information as I can, but a good answer to just one of them would probably solve my problem.

  • If I'm not using features specific to newer versions of Visual Studio, is it possible to set up a solution which can be opened and run without modification in as many versions as possible (ie. 2008, 2010, or 2012)? If so, how?

  • If I set the Platform Toolset to v90 (VS2008) from within Visual Studio 2012, and it's able to build and run, does this mean that it will build and run for users with VS2012, VS2010, and VS2008?

  • What exactly does the <inherit for parent or project defaults> option do? What would the project defaults be set up as? Can this be used to tell Visual Studio to try to using whichever installed Platform Toolset will work.

  • Are there any other options besides Platform Toolset in Visual Studio that I can set to increase compatibility with others' development environments?

4

1 回答 1

6

这是一个有点棘手的情况。这里的潜在问题之一是 VS2010 和 VS2012 使用 MSBuild 来构建 C++ 项目,但 VS2008 将其外包给了 VCBuild。您可以通过比较项目文件来看到这一点。VS2010/VS2012 使用 .vcxproj,而 VS2008 使用 .vcproj。

如果我没有使用特定于 Visual Studio 较新版本的功能,是否可以设置一个解决方案,无需修改即可在尽可能多的版本(即 2008、2010 或 2012)中打开和运行?如果是这样,怎么做?

为了获得最大的兼容性,您希望以最小的公分母为目标(即本例中的 vc90)。请注意,当您进行升级时,解决方案文件和项目文件会升级到最新版本,这可能会破坏与旧版本 Visual Studio 的兼容性。

如果我在 Visual Studio 2012 中将平台工具集设置为 v90 (VS2008),并且它能够构建和运行,这是否意味着它将为使用 VS2012、VS2010 和 VS2008 的用户构建和运行?

不是真的,由于上述 .vcxproj / .vcproj 冲突。

例如,我目前有一组 .vcxproj 文件和一个专为 VS2010 设计的解决方案。我使用 VS2012 作为我的 IDE,所以当我在 VS2012 中打开 VS2010 解决方案时,我选择不升级它并按原样打开它。就项目文件而言,VS2012 及更高版本应该向后兼容回 VS2010。

为了在开发环境中实现最大的兼容性,我的建议是使用 VS2010 的解决方案作为基准,以 v100 为目标。开发人员可以使用任何比它更新的版本,并且它们应该可以优雅地协同工作。

于 2013-11-29T19:39:17.010 回答