Tôi đã cài đặt Visual Studio 2013 và 2015 cạnh nhau. Tôi vừa nâng cấp giải pháp kết hợp (C#, C++, C++/CLI) đến năm 2015 và đặt Platform Toolset thành v140.Xây dựng Visual Studio 2015 Dự án C++ (v140) của MSBuild Failed - v140 không thể tìm thấy
Việc xây dựng từ Visual Studio hoạt động tốt, nhưng nó không thể được biên dịch từ MSBuild. Tôi sử dụng MSBuild 14 và MSBuild phàn nàn rằng không thể tìm thấy v140, nhưng nó là vô nghĩa, bởi vì v140 được cài đặt trên máy tính trong "c: \ Program Files (x86) \ MSBuild \ Microsoft.Cpp \ v4.0 \ V140".
Không thể thực hiện lời khuyên về nâng cấp giải pháp vì giải pháp đã được nâng cấp và không có mục nào trong menu ngữ cảnh giải pháp.
Nếu tôi chuyển công cụ Nền tảng của dự án thành v120, nó hoạt động.
chi tiết:
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:
- Có một số dự án bị bỏ qua hình thức gỡ lỗi X86. Đây là cố ý.
- Dự án đã được tạo ban đầu trong VS2008, sau đó nâng cấp lên VS2013, sau đó nâng cấp lên VS2015.
- Có hai Visual Studio được cài đặt trên máy tính này (Cộng đồng 2013 và Cộng đồng 2015). 2013 đã được cài đặt đầu tiên, năm 2015 sau đó.
Các thiết lập registry trông giống như:
UPDATE2: Minimal, Complete, and Verifiable example
Tôi đã tạo rỗng C++ Console Application trong Visual Studio 2015:
https://dl.dropboxusercontent.com/u/53387801/ConsoleApplication_v140.zip
#include "stdafx.h"
int main()
{
return 0;
}
tôi có thể xây dựng nó trong Visual Studio, nhưng tôi phải đối mặt với cùng một vấn đề trong 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:\>
SOLVED:
Môi trường VisualStudioVersion biến được thiết lập để 12.0 thay vì 14.0 Thay đổi giá trị thành 14.0 đã giải quyết được vấn đề.
Ứng dụng giao diện điều khiển đơn giản bắt đầu hoạt động ngay lập tức sau khi biến môi trường VisualStudioVersion thay đổi và sau khi cửa sổ đăng xuất, đăng nhập.
Dự án gốc vẫn không thể được xây dựng sau khi thay đổi biến môi trường VisualStudioVersion. Menu ngữ cảnh giải pháp mục tiêu lại xuất hiện trong Visual Studio 2015. Vì vậy, tôi nhắm mục tiêu lại giải pháp. Sau khi retargeting giải pháp vẫn không thể được biên dịch (không tìm thấy v140). Cuối cùng, tôi đã thay đổi bộ công cụ nền tảng từ v140 (chưa được cài đặt) đến Visual Studio 2015 (v140).Bây giờ giải pháp có thể được biên dịch từ Visual Studio và MSBuild.
Rất nhiều người đã xây dựng các dự án C++ bằng bộ công cụ v140. VS 2015 sẽ không được phát hành mà không thể thực hiện được. Tình hình của bạn dường như là duy nhất và tôi không nghĩ có đủ thông tin để mọi người giải quyết nó. Bạn có thể thử xem liệu bạn có thể tạo MCVE hay không. –
Tôi đã thử nghiệm MCVE và tôi phải đối mặt với cùng một vấn đề. Liên kết đến tệp zip được cung cấp. – qub1n
Kiểm tra xem bạn đã không định nghĩa biến môi trường 'VisualStudioVersion' hay là tệp giải pháp và dự án của bạn không định nghĩa lại nó một cái gì đó khác hơn 14.xxx –