使用仅安装 Visual Studio 2017 的系统构建 Visual Studio 2010 C++ 项目

Building Visual Studio 2010 C++ project with a system that has only Visual Studio 2017 installed

我们目前正在升级系统,希望借此机会从 VS 2010 升级到 VS 2017。

在切换之前,我们运行 对现有项目(C++ 和 C#)进行了一些测试。编译和调试 C# 项目如预期般顺利进行。

我们有一个相当大的 C++ 解决方案,我们也想在 VS 2017 中继续开发,但现在我们不想升级平台工具集或 sdk 版本。

刚刚安装VS 2017编译解决方案报错:

The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution".

在谷歌搜索时我发现了以下问题:How to install Visual Studio Build Tools 2010 on Visual Studio 2015 Community?

这与我们面临的问题类似。我尝试从 Windows 7 SDK 安装 Headers 和工具。我还安装了 C++ 编译器更新,但现在出现以下错误(对于每个项目):

  • Could not find WindowsSDKDir variable from the registry. TargetFrameworkVersion or PlatformToolset may be set to an invalid version number. in C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets on line 297

  • Required file "" is missing. in C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Platforms\Win32\Microsoft.Cpp.Win32.Targets on line 153

上述错误中提到的元素具有以下文本:

<!-- Rest of the sources -->
<CL Condition="'%(ClCompile.PrecompiledHeader)' != 'Create' and '%(ClCompile.ExcludedFromBuild)'!='true'"
    BuildingInIDE                      ="$(BuildingInsideVisualStudio)"
    Sources                            ="@(ClCompile)"

    AdditionalIncludeDirectories       ="%(ClCompile.AdditionalIncludeDirectories)"
    AdditionalOptions                  ="%(ClCompile.AdditionalOptions)"
    AdditionalUsingDirectories         ="%(ClCompile.AdditionalUsingDirectories)"
    AssemblerListingLocation           ="%(ClCompile.AssemblerListingLocation)"
    AssemblerOutput                    ="%(ClCompile.AssemblerOutput)"
    BasicRuntimeChecks                 ="%(ClCompile.BasicRuntimeChecks)"
    BrowseInformation                  ="%(ClCompile.BrowseInformation)"
    BrowseInformationFile              ="%(ClCompile.BrowseInformationFile)"
    BufferSecurityCheck                ="%(ClCompile.BufferSecurityCheck)"
    CallingConvention                  ="%(ClCompile.CallingConvention)"
    CompileAsManaged                   ="%(ClCompile.CompileAsManaged)"
    CompileAs                          ="%(ClCompile.CompileAs)"
    DebugInformationFormat             ="%(ClCompile.DebugInformationFormat)"
    DisableLanguageExtensions          ="%(ClCompile.DisableLanguageExtensions)"
    DisableSpecificWarnings            ="%(ClCompile.DisableSpecificWarnings)"
    EnableEnhancedInstructionSet       ="%(ClCompile.EnableEnhancedInstructionSet)"
    EnableFiberSafeOptimizations       ="%(ClCompile.EnableFiberSafeOptimizations)"
    EnablePREfast                      ="%(ClCompile.EnablePREfast)"
    ErrorReporting                     ="%(ClCompile.ErrorReporting)"
    ExceptionHandling                  ="%(ClCompile.ExceptionHandling)"
    ExcludedInputPaths                 ="$(ExcludePath)"
    ExpandAttributedSource             ="%(ClCompile.ExpandAttributedSource)"
    FavorSizeOrSpeed                   ="%(ClCompile.FavorSizeOrSpeed)"
    FloatingPointExceptions            ="%(ClCompile.FloatingPointExceptions)"
    FloatingPointModel                 ="%(ClCompile.FloatingPointModel)"
    ForceConformanceInForLoopScope     ="%(ClCompile.ForceConformanceInForLoopScope)"
    ForcedIncludeFiles                 ="%(ClCompile.ForcedIncludeFiles)"
    ForcedUsingFiles                   ="%(ClCompile.ForcedUsingFiles)"
    FunctionLevelLinking               ="%(ClCompile.FunctionLevelLinking)"
    GenerateXMLDocumentationFiles      ="%(ClCompile.GenerateXMLDocumentationFiles)"
    IgnoreStandardIncludePath          ="%(ClCompile.IgnoreStandardIncludePath)"
    InlineFunctionExpansion            ="%(ClCompile.InlineFunctionExpansion)"
    IntrinsicFunctions                 ="%(ClCompile.IntrinsicFunctions)"
    MinimalRebuild                     ="%(ClCompile.MinimalRebuild)"
    MultiProcessorCompilation          ="%(ClCompile.MultiProcessorCompilation)"
    ObjectFileName                     ="%(ClCompile.ObjectFileName)"
    OmitDefaultLibName                 ="%(ClCompile.OmitDefaultLibName)"
    OmitFramePointers                  ="%(ClCompile.OmitFramePointers)"
    OpenMPSupport                      ="%(ClCompile.OpenMPSupport)"
    Optimization                       ="%(ClCompile.Optimization)"
    PrecompiledHeader                  ="%(ClCompile.PrecompiledHeader)"
    PrecompiledHeaderFile              ="%(ClCompile.PrecompiledHeaderFile)"
    PrecompiledHeaderOutputFile        ="%(ClCompile.PrecompiledHeaderOutputFile)"
    PreprocessKeepComments             ="%(ClCompile.PreprocessKeepComments)"
    PreprocessorDefinitions            ="%(ClCompile.PreprocessorDefinitions)"
    PreprocessSuppressLineNumbers      ="%(ClCompile.PreprocessSuppressLineNumbers)"
    PreprocessToFile                   ="%(ClCompile.PreprocessToFile)"
    ProcessorNumber                    ="%(ClCompile.ProcessorNumber)"
    ProgramDataBaseFileName            ="%(ClCompile.ProgramDataBaseFileName)"
    RuntimeLibrary                     ="%(ClCompile.RuntimeLibrary)"
    RuntimeTypeInfo                    ="%(ClCompile.RuntimeTypeInfo)"
    ShowIncludes                       ="%(ClCompile.ShowIncludes)"
    SmallerTypeCheck                   ="%(ClCompile.SmallerTypeCheck)"
    StringPooling                      ="%(ClCompile.StringPooling)"
    StructMemberAlignment              ="%(ClCompile.StructMemberAlignment)"
    SuppressStartupBanner              ="%(ClCompile.SuppressStartupBanner)"
    TreatSpecificWarningsAsErrors      ="%(ClCompile.TreatSpecificWarningsAsErrors)"
    TreatWarningAsError                ="%(ClCompile.TreatWarningAsError)"
    TreatWChar_tAsBuiltInType          ="%(ClCompile.TreatWChar_tAsBuiltInType)"
    UndefineAllPreprocessorDefinitions ="%(ClCompile.UndefineAllPreprocessorDefinitions)"
    UndefinePreprocessorDefinitions    ="%(ClCompile.UndefinePreprocessorDefinitions)"
    UseFullPaths                       ="%(ClCompile.UseFullPaths)"
    UseUnicodeForAssemblerListing      ="%(ClCompile.UseUnicodeForAssemblerListing)"
    WarningLevel                       ="%(ClCompile.WarningLevel)"
    WholeProgramOptimization           ="%(ClCompile.WholeProgramOptimization)"
    XMLDocumentationFileName           ="%(ClCompile.XMLDocumentationFileName)"
    CreateHotpatchableImage            ="%(CLCompile.CreateHotpatchableImage)"

    TrackerLogDirectory                ="%(ClCompile.TrackerLogDirectory)"

    TLogReadFiles                      ="@(CLTLogReadFiles)"
    TLogWriteFiles                     ="@(CLTLogWriteFiles)"
    ToolExe                            ="$(CLToolExe)"
    ToolPath                           ="$(CLToolPath)"
    TrackFileAccess                    ="$(TrackFileAccess)"
    MinimalRebuildFromTracking         ="%(ClCompile.MinimalRebuildFromTracking)"
    ToolArchitecture                   ="$(CLToolArchitecture)"
    TrackerFrameworkPath               ="$(CLTrackerFrameworkPath)"
    TrackerSdkPath                     ="$(CLTrackerSdkPath)"
    TrackedInputFilesToIgnore      ="@(ClNoDependencies)"

    AcceptableNonZeroExitCodes         ="%(ClCompile.AcceptableNonZeroExitCodes)"
    YieldDuringToolExecution           ="$(ClYieldDuringToolExecution)"
>

寻找解决警告的方法,找不到 WindowsSDKDir 导致我 this question

将平台工具集更改为 "Windows7.1SDK" 可消除 "Could not find WindowsSDKDir variable from the registry." 错误,但缺少 "Required file ""。"错误仍然存​​在。

安装 Visual Studio 2010 C++ Express 确实解决了问题(至少对于编译和 运行 Release 中的解决方案)。

有没有一种方法可以使用 VS 2017 而无需升级我们的项目而无需安装 VS 2010?

这显然是不可能的。您必须安装 Visual Studio 2010 或将工具集升级到 Visual Studio 2017 as outlined in this blogpost - and comments.