web-dev-qa-db-fra.com

Échec de la création du projet Visual Studio 2015 C ++ (v140) par MSBuild - v140 est introuvable

J'ai installé Visual Studio 2013 et 2015 côte à côte. Je viens de mettre à niveau la solution combinée (C #, C++, C++/CLI) vers 2015 et de définir Platform Toolset sur v140.

La génération à partir de Visual Studio fonctionne correctement, mais elle ne peut pas être compilée à partir de MSBuild. J'utilise MSBuild 14 et MSBuild se plaint de ne pas trouver la v140, mais cela n'a aucun sens, car la v140 est installée sur l'ordinateur dans "c:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140".

Les conseils sur la mise à niveau de la solution ne peuvent pas être effectués, car la solution est déjà mise à niveau et il n'y a pas un tel élément dans le menu contextuel de la solution.

Si je change les outils de la plateforme du projet en v120, cela fonctionne.

Détails:

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.

MISE À JOUR:

  • Il y a des projets ignorés du Debug X86. C'est intentionnel.
  • Le projet a été initialement créé dans VS2008, puis mis à niveau vers VS2013, puis mis à niveau vers VS2015.
  • Il y a deux Visual Studios installés sur cet ordinateur (Communauté 2013 et Communauté 2015). 2013 a été installé en premier, 2015 plus tard.

Les paramètres du registre ressemblent à: enter image description here

MS Build registry settings

UPDATE2: exemple minimal, complet et vérifiable

J'ai créé une application console C++ vide dans Visual Studio 2015:

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

#include "stdafx.h"

int main()
{
    return 0;
}

Je peux le construire dans Visual Studio, mais je fais face au même problème dans 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:\>

RÉSOLU:

La variable d'environnement VisualStudioVersion a été définie sur 12.0 au lieu de 14.0 La modification de la valeur sur 14.0 a résolu le problème.

L'application de console simple a commencé à fonctionner immédiatement après la modification de la variable d'environnement VisualStudioVersion et après la déconnexion de Windows, la connexion.

Le projet d'origine n'a toujours pas pu être généré après avoir modifié la variable d'environnement VisualStudioVersion. Un menu contextuel de la solution de reciblage est apparu dans Visual Studio 2015. J'ai donc reciblé la solution. Après reciblage, la solution n'a toujours pas pu être compilée (v140 introuvable). Enfin, j'ai changé le jeu d'outils de plateforme de v140 (non installé) à Visual Studio 2015 (v140) . Désormais, la solution peut également être compilée à partir de Visual Studio et MSBuild.

10
Tomas Kubes

Votre problème est que vous définissez la variable d'environnement VisualStudioVersion sur 12.0. Cela indique à MSBuild d'utiliser les outils Visual Studio 2013 (V120), qui ne prennent pas en charge les outils de génération Visual Studio 2015 (V140). Si vous désactivez cette variable d'environnement ou passez le /p:VisualStudioVersion=14.0 option pour MSBuild votre projet, devrait se construire. (Ou au moins dépasser cette erreur).

Vous pouvez trouver plus d'informations sur la variable VisualStudioVersion dans une entrée de blog MSDN intitulée compatibilité du projet Visual Studio et VisualStudioVersion .

11
Ross Ridge

Une solution consiste à modifier simplement l'ensemble d'outils de plate-forme disponible dans votre système. Ensuite, ça va bien.

2
Abc