使用 MSBuild 命令行实用程序时出错
Posted
技术标签:
【中文标题】使用 MSBuild 命令行实用程序时出错【英文标题】:Error using MSBuild Command Line utility 【发布时间】:2012-03-01 00:17:02 【问题描述】:我有一个 Visual Studio 2008 解决方案文件和一台 Windows 7(64 位)机器。
我正在尝试使用 MSBuild 命令从 *.sln 文件构建解决方案,但出现错误。
我收到以下错误:“MSB4018:“ResolveVCProjectOutput”任务意外失败(参见http://connect.microsoft.com/VisualStudio/feedback/details/349531/msb4018-the-resolvevcprojectoutput-task-failed-unexpectedly)。
使用64位版本的msbuild.exe修复了这个错误,但是带来了这个错误: MSB3411:无法加载 Visual C++ 组件“VCBuild.exe”
为了解决这个问题,我将 C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages 添加到我的 PATH 中。
现在我收到链接器错误和以下警告:
警告 MSB3428:无法加载 Visual C++ 组件“VCProjectEngine.dll”
警告 MSB3425:无法解析 VC 项目引用“something.vcproj”。
此外,项目似乎没有按照 .sln 文件指定的顺序构建。
我现在再次收到 MSB4018:“ResolveVCProjectOutput”任务意外失败错误。
这可能与 64 位 msbuild.exe 调用 32 位 dll 有关吗? 或者它可能与在我的 Visual Studio 设置中的某些路径中有/没有预期的引号有关? 或者这可能与乱序构建的项目有关? 以下是 诊断 详细级别的输出:
Initial Items:
_SolutionProjectProjects
..\SOME_LIB\trunk\msvc_2008\SOME_LIB_LIB.vcproj
helpers\msvc_2005\helpers.vcproj
My Sandbox\My Sandbox.vcproj
Building with tools version "2.0".
Target "ValidateSolutionConfiguration: (TargetId:2)" in file "" from project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (entry point):
Task "Error" skipped, due to false condition; (('$(CurrentSolutionConfigurationContents)' == '') and ('$(SkipInvalidConfigurations)' != 'true')) was evaluated as (('<SolutionConfiguration xmlns=""><ProjectConfiguration Project="A1B06ADE-974B-4B50-A77E-2FB1AC97FFB5">Debug|Win32</ProjectConfiguration><ProjectConfiguration Project="28215158-9138-4D90-8B11-461278300EF3">Debug|Win32</ProjectConfiguration><ProjectConfiguration Project="3901755B-0BE2-479D-81BE-B98B61BF337F">Debug|Win32</ProjectConfiguration></SolutionConfiguration>' == '') and ('' != 'true')).
Task "Warning" skipped, due to false condition; (('$(CurrentSolutionConfigurationContents)' == '') and ('$(SkipInvalidConfigurations)' == 'true')) was evaluated as (('<SolutionConfiguration xmlns=""><ProjectConfiguration Project="A1B06ADE-974B-4B50-A77E-2FB1AC97FFB5">Debug|Win32</ProjectConfiguration><ProjectConfiguration Project="28215158-9138-4D90-8B11-461278300EF3">Debug|Win32</ProjectConfiguration><ProjectConfiguration Project="3901755B-0BE2-479D-81BE-B98B61BF337F">Debug|Win32</ProjectConfiguration></SolutionConfiguration>' == '') and ('' == 'true')).
Using "Message" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "Message" (TaskId:2)
Building solution configuration "Debug|Win32". (TaskId:2)
Done executing task "Message". (TaskId:2)
Done building target "ValidateSolutionConfiguration" in project "My Sandbox.sln".: (TargetId:2)
Target "ValidateToolsVersions: (TargetId:3)" in file "" from project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (entry point):
Task "Error" skipped, due to false condition; ('$(MSBuildToolsVersion)' == '2.0' and ('$(ProjectToolsVersion)' != '2.0' and '$(ProjectToolsVersion)' != '')) was evaluated as ('3.5' == '2.0' and ('' != '2.0' and '' != '')).
Done building target "ValidateToolsVersions" in project "My Sandbox.sln".: (TargetId:3)
Target "Build: (TargetId:4)" in file "" from project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (entry point):
Task "MSBuild" skipped, due to false condition; (@(BuildLevel0) != '') was evaluated as ( != '').
Task "Message" skipped, due to false condition; (@(SkipLevel0) != '') was evaluated as ( != '').
Task "Warning" skipped, due to false condition; (@(MissingConfigLevel0) != '') was evaluated as ( != '').
Using "CallTarget" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "CallTarget" (TaskId:3)
Target "helpers: (TargetId:5)" in file "" from project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (target "Build" depends on it):
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Using "VCBuild" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "VCBuild" (TaskId:4)
Locating vcbuild.exe: Visual C++ Express is not installed on this computer. (TaskId:4)
Locating vcbuild.exe: falling back to the system PATH variable. (TaskId:4)
Command: (TaskId:4)
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\VCBuild.exe "C:\Users\cmorris\Documents\Projects\My Sandbox\helpers\msvc_2005\helpers.vcproj" "Debug|Win32" (TaskId:4)
The "VCBuild" task is using "VCBuild.exe" from "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\VCBuild.exe". (TaskId:4)
Microsoft (R) Visual C++ Project Builder - Command Line Version 9.00.21022 (TaskId:4)
Copyright (C) Microsoft Corporation. All rights reserved. (TaskId:4)
(TaskId:4)
Build started: Project: helpers, Configuration: Debug|Win32 (TaskId:4)
helpers - up-to-date (TaskId:4)
Done executing task "VCBuild". (TaskId:4)
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Release_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Release_static') and ('Win32' == 'Win32') ).
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Release') and ('Win32' == 'Win32') ).
Done building target "helpers" in project "My Sandbox.sln".: (TargetId:5)
Target "SOME_LIB_LIB: (TargetId:6)" in file "" from project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (target "Build" depends on it):
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Task "VCBuild" (TaskId:5)
Locating vcbuild.exe: Visual C++ Express is not installed on this computer. (TaskId:5)
Locating vcbuild.exe: falling back to the system PATH variable. (TaskId:5)
Command: (TaskId:5)
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\VCBuild.exe "C:\Users\cmorris\Documents\Projects\My Sandbox\..\SOME_LIB\trunk\msvc_2008\SOME_LIB_LIB.vcproj" "Debug|Win32" (TaskId:5)
The "VCBuild" task is using "VCBuild.exe" from "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\vcpackages\VCBuild.exe". (TaskId:5)
Microsoft (R) Visual C++ Project Builder - Command Line Version 9.00.21022 (TaskId:5)
Copyright (C) Microsoft Corporation. All rights reserved. (TaskId:5)
(TaskId:5)
Build started: Project: SOME_LIB_LIB, Configuration: Debug|Win32 (TaskId:5)
SOME_LIB_LIB - up-to-date (TaskId:5)
Done executing task "VCBuild". (TaskId:5)
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Release_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Release_static') and ('Win32' == 'Win32') ).
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Release') and ('Win32' == 'Win32') ).
Done building target "SOME_LIB_LIB" in project "My Sandbox.sln".: (TargetId:6)
Done executing task "CallTarget". (TaskId:3)
Task "MSBuild" skipped, due to false condition; (@(BuildLevel1) != '') was evaluated as ( != '').
Task "Message" skipped, due to false condition; (@(SkipLevel1) != '') was evaluated as ( != '').
Task "Warning" skipped, due to false condition; (@(MissingConfigLevel1) != '') was evaluated as ( != '').
Task "CallTarget" (TaskId:6)
Target "helpers" skipped. Previously built successfully.
Target "SOME_LIB_LIB" skipped. Previously built successfully.
Target "My Sandbox: (TargetId:7)" in file "" from project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (target "Build" depends on it):
Task "ResolveVCProjectOutput" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Using "CreateItem" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "CreateItem" (TaskId:7)
Done executing task "CreateItem". (TaskId:7)
Task "ResolveVCProjectOutput" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Task "CreateItem" (TaskId:8)
Done executing task "CreateItem". (TaskId:8)
Task "CreateTemporaryVCProject" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Task "VCBuild" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Task "Delete" skipped, due to false condition; ( ('$(Configuration)' == 'Debug_static') and ('$(Platform)' == 'Win32') ) was evaluated as ( ('Debug' == 'Debug_static') and ('Win32' == 'Win32') ).
Using "ResolveVCProjectOutput" task from assembly "Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
Task "ResolveVCProjectOutput" (TaskId:9)
Resolving VC project reference "C:\Users\cmorris\Documents\Projects\My Sandbox\helpers\msvc_2005\helpers.vcproj". (TaskId:9)
MSBUILD : error MSB4018: The "ResolveVCProjectOutput" task failed unexpectedly. [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: System.ArgumentException: Illegal characters in path. [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at System.IO.Path.CheckInvalidPathChars(String path) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at System.IO.Path.IsPathRooted(String path) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.Tasks.ResolveVCProjectOutput.ResolveUsingVCEngineObjectModel(ITaskItem projectRef, String configName, String& resolvedAssemblyPath, String& resolvedImportLibraryPath) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.Tasks.ResolveVCProjectOutput.Execute() [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
Done executing task "ResolveVCProjectOutput" -- FAILED. (TaskId:9)
Done building target "My Sandbox" in project "My Sandbox.sln" -- FAILED.: (TargetId:7)
Done executing task "CallTarget" -- FAILED. (TaskId:6)
Done building target "Build" in project "My Sandbox.sln" -- FAILED.: (TargetId:4)
Done Building Project "C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (build target(s)) -- FAILED.
Deferred Messages
Detailed Build Summary
======================
(TaskId:0)
============================== Build Hierarchy (IDs represent configurations) =====================================================
Id : Exclusive Time Total Time Path (Targets)
----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
0 : 0.944s 0.944s C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln (build) (TaskId:0)
============================== Node Utilization (IDs represent configurations) ====================================================
Timestamp: 1 Duration Cumulative
----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
634661562995558093: 0 0.944s 0.944s ################## (TaskId:0)
-----------------------------------------------------------------------------------------------------------------------------------
Utilization: 100.0 Average Utilization: 100.0 (TaskId:0)
Project Performance Summary:
943 ms C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln 1 calls
943 ms build 1 calls
Target Performance Summary:
0 ms ValidateToolsVersions 1 calls
20 ms ValidateSolutionConfiguration 1 calls
149 ms My Sandbox 1 calls
367 ms helpers 1 calls
385 ms SOME_LIB_LIB 1 calls
913 ms Build 1 calls
Task Performance Summary:
2 ms CreateItem 2 calls
20 ms Message 1 calls
146 ms ResolveVCProjectOutput 1 calls
751 ms VCBuild 2 calls
913 ms CallTarget 2 calls
Build FAILED.
"C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln" (build target) (1) ->
(My Sandbox target) ->
MSBUILD : error MSB4018: The "ResolveVCProjectOutput" task failed unexpectedly. [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: System.ArgumentException: Illegal characters in path. [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at System.IO.Path.CheckInvalidPathChars(String path) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at System.IO.Path.IsPathRooted(String path) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.Tasks.ResolveVCProjectOutput.ResolveUsingVCEngineObjectModel(ITaskItem projectRef, String configName, String& resolvedAssemblyPath, String& resolvedImportLibraryPath) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.Tasks.ResolveVCProjectOutput.Execute() [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
MSBUILD : error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask, Boolean& taskResult) [C:\Users\cmorris\Documents\Projects\My Sandbox\My Sandbox.sln]
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.97
【问题讨论】:
【参考方案1】:“使用64位版本的msbuild.exe修复了这个错误,但是带来了这个错误:MSB3411: Could not load the Visual C++ component “VCBuild.exe””
64 位 MSBuild 无法加载 VCBuild.exe,因为它是 32 位应用程序。
通过MsBuild直接构建你的解决方案有问题吗?
msbuild SlnFolders.sln /t:build ...
【讨论】:
是的。我的帖子是关于尝试使用 msbuild 从命令行直接构建解决方案。【参考方案2】:刚刚遇到同样的问题。我从%windir%\Microsoft.NET
的Framework64
目录显式运行msbuild
。但是路径设置错了。
运行vcvars64
首先解决了问题。
【讨论】:
以上是关于使用 MSBuild 命令行实用程序时出错的主要内容,如果未能解决你的问题,请参考以下文章
Wildfly 10:尝试实现 Java 并发实用程序时出错