Подтвердить что ты не робот

Создание проекта Visual Studio 2015 С++ (v140) с помощью MSBuild Failed - v140 не найден

У меня есть Visual Studio 2013 и 2015, установленные бок о бок. Я только что обновил комбинированное решение (С#, С++, С++/CLI) до 2015 года и установил Platform Toolset в v140.

Сборка из Visual Studio отлично работает, но она не может быть скомпилирована из MSBuild. Я использую MSBuild 14 и MSBuild, которые не могут найти v140, но это вздор, потому что v140 установлен на компьютере в "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140".

Рекомендации по обновлению решения не могут быть выполнены, потому что решение уже обновлено, и в контекстном меню решения нет такого элемента.

Если я переключу инструменты платформы проекта на v120, он будет работать.

Подробнее:

c:\git\hewerMaster>"c:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe"  c:\git
\hewerMaster\Hewer.sln /property:Configuration=Debug /property:Platform=x86
Microsoft (R) Build Engine version 14.0.23107.0
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
Build started 9/12/2015 4:00:25 PM.
Project "c:\git\hewerMaster\Hewer.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|x86".
ValidateProjects:
  The project "HewerDotNetWrapper" is not selected for building in solution con
  figuration "Debug|x86".
  The project "VisualHewer" is not selected for building in solution configurat
  ion "Debug|x86".
  The project "UnitTestWrapper" is not selected for building in solution config
  uration "Debug|x86".
  The project "ParamsFormatConverter" is not selected for building in solution
  configuration "Debug|x86".
  The project "UnitTestGenerator" is not selected for building in solution conf
  iguration "Debug|x86".
  The project "HewerUnitTestDotNet" is not selected for building in solution co
  nfiguration "Debug|x86".
Project "c:\git\hewerMaster\Hewer.sln" (1) is building "c:\git\hewerMaster\Hewe
rRedirect\HewerRedirect.csproj" (2) on node 1 (default targets).
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with resp
ect to the input files.
_CopyAppConfigFile:
Skipping target "_CopyAppConfigFile" because all output files are up-to-date wi
th respect to the input files.
CopyFilesToOutputDirectory:
  HewerRedirect -> c:\git\hewerMaster\anyCPU\Debug\pbrain-hewer.exe
Done Building Project "c:\git\hewerMaster\HewerRedirect\HewerRedirect.csproj" (
default targets).

Project "c:\git\hewerMaster\Hewer.sln" (1) is building "c:\git\hewerMaster\Hewe
r\Hewer.vcxproj" (3) on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.t
argets(64,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140
') cannot be found. To build using the v140 build tools, please install v140 bu
ild tools.  Alternatively, you may upgrade to the current Visual Studio tools b
y selecting the Project menu or right-click the solution, and then selecting "U
pgrade Solution...". [c:\git\hewerMaster\Hewer\Hewer.vcxproj]
Done Building Project "c:\git\hewerMaster\Hewer\Hewer.vcxproj" (default targets
) -- FAILED.

Done Building Project "c:\git\hewerMaster\Hewer.sln" (default targets) -- FAILE
D.


Build FAILED.

UPDATE:

  • Есть некоторые пропущенные проекты Debug X86. Это намеренно.
  • Проект был первоначально создан в VS2008, затем обновлен до VS2013, а затем обновлен до VS2015.
  • На этом компьютере установлено два Visual Studios (Community Community Community Community Community Community Community Community Community Community Server 2010). 2013 был установлен первым, 2015 позже.

Настройки реестра выглядят так: введите описание изображения здесь

MS Build registry settings

UPDATE2: Минимальный, полный и проверенный пример

Я создал пустую консольную консоль С++ в Visual Studio 2015:

https://dl.dropboxusercontent.com/u/53387801/ConsoleApplication_v140.zip

#include "stdafx.h"

int main()
{
    return 0;
}

Я могу создать его в Visual Studio, но я столкнулся с той же проблемой в MSBuild:

c:\>"c:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild" "C:\temp\vs2015_simplest\C
onsoleApplication1\consoleApplication1.sln"
Microsoft (R) Build Engine version 14.0.23107.0
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
Build started 9/16/2015 10:16:20 AM.
Project "C:\temp\vs2015_simplest\ConsoleApplication1\consoleApplication1.sln" o
n node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|x64".
Project "C:\temp\vs2015_simplest\ConsoleApplication1\consoleApplication1.sln" (
1) is building "C:\temp\vs2015_simplest\ConsoleApplication1\ConsoleApplication1
\ConsoleApplication1.vcxproj" (2) on node 1 (default targets).
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.t
argets(64,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v140
') cannot be found. To build using the v140 build tools, please install v140 bu
ild tools.  Alternatively, you may upgrade to the current Visual Studio tools b
y selecting the Project menu or right-click the solution, and then selecting "U
pgrade Solution...". [C:\temp\vs2015_simplest\ConsoleApplication1\ConsoleApplic
ation1\ConsoleApplication1.vcxproj]
Done Building Project "C:\temp\vs2015_simplest\ConsoleApplication1\ConsoleAppli
cation1\ConsoleApplication1.vcxproj" (default targets) -- FAILED.

Done Building Project "C:\temp\vs2015_simplest\ConsoleApplication1\consoleAppli
cation1.sln" (default targets) -- FAILED.


Build FAILED.

"C:\temp\vs2015_simplest\ConsoleApplication1\consoleApplication1.sln" (default
target) (1) ->
"C:\temp\vs2015_simplest\ConsoleApplication1\ConsoleApplication1\ConsoleApplica
tion1.vcxproj" (default target) (2) ->
(PlatformPrepareForBuild target) ->
  C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform
.targets(64,5): error MSB8020: The build tools for v140 (Platform Toolset = 'v1
40') cannot be found. To build using the v140 build tools, please install v140
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
"Upgrade Solution...". [C:\temp\vs2015_simplest\ConsoleApplication1\ConsoleAppl
ication1\ConsoleApplication1.vcxproj]

    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:00.14

c:\>

РЕШИТЬ:

Среда переменная VisualStudioVersion была установлена ​​в 12.0 вместо 14.0. Изменение значения до 14.0 решило проблему.

Простое консольное приложение начало работать сразу же после изменения переменной среды VisualStudioVersion и после выхода из системы, войдите в систему.

Оригинальный проект по-прежнему не может быть создан после изменения переменной среды VisualStudioVersion. В Visual Studio 2015 появилось контекстное меню решения перенастройки. Поэтому я перенацелю решение. После перенацеливания решение все еще невозможно скомпилировать (v140 не найден). Наконец, я изменил набор инструментов платформы от v140 (не установлен) до Visual Studio 2015 (v140). Теперь решение может быть скомпилировано также из Visual Studio и MSBuild.

4b9b3361

Ответ 1

Ваша проблема в том, что вы устанавливаете переменную среды VisualStudioVersion на 12.0. Это говорит MSBuild использовать инструменты Visual Studio 2013 (V120), которые не поддерживают инструменты сборки Visual Studio 2015 (V140). Если вы отключите эту переменную среды или передадите параметр /p:VisualStudioVersion=14.0 в MSBuild, ваш проект должен построить. (Или, по крайней мере, пройти эту ошибку).

Более подробную информацию о переменной VisualStudioVersion можно найти в записи блога MSDN под названием совместимость проектов Visual Studio и VisualStudioVersion.

Ответ 2

Одним из решений является простое изменение набора инструментов платформы, доступного в вашей системе. Тогда он строит отлично.