问题描述
我们正在将我们的编译系统迁移到msbuild
,我们发现一些项目报告了以下错误:
We are migrating our compilation system to msbuild
, and we've found that some projects report the following error:
c:\src\libs\a_lib\A\A.vcxproj:错误 MSB4057:目标C"项目中不存在.
c:\src\libs\a_lib\B\B.vcxproj:错误 MSB4057:目标C"项目中不存在.
c:\src\libs\a_lib\B\B.vcxproj : error MSB4057: The target "C" does not exist in the project.
c:\src\libs\a_lib\C\C.vcxproj:错误 MSB4057:目标C"项目中不存在.
c:\src\libs\a_lib\C\C.vcxproj : error MSB4057: The target "C" does not exist in the project.
c:\src\libs\a_lib\D\D.vcxproj:错误 MSB4057:目标C"项目中不存在.
c:\src\libs\a_lib\D\D.vcxproj : error MSB4057: The target "C" does not exist in the project.
编译行是
msbuild "c:\src\libs\a_lib\a_lib.sln" /nologo "/target:C" /t:build "/p:Configuration=Release" "/p:Platform=Win32"
可以看出,该解决方案有多个项目.项目本身存在于解决方案中,可以从 VS IDE 中进行编译.此外,其他目标也不会失败(例如:A、B、D).
As can be seen, the solution has several projects. The project itself exists in the solution and can be compiled from within the VS IDE. Also, other targets do not fail (following the example: A, B, D).
我们之前的编译行在同一个项目上正常工作:
Our previous compilation line worked correctly on the same project:
devenv "c:\src\libs\a_lib\a_lib.sln" /project "C" /build /nologo "Release|Win32"
推荐答案
问题来自这样一个事实,即此类项目嵌套在解决方案资源管理器中的解决方案文件夹(在本例中为 Tests
)中.目标名称必须包含此类文件夹的名称(Tests\C
),因此正确的编译行是
The problem comes from the fact that such project is nested inside a solution folder (Tests
in this example) in the Solution Explorer. Target name must include the name of such folders (Tests\C
), so the correct compilation line is
msbuild "c:\src\libs\a_lib\a_lib.sln" /nologo "/target:Tests\C" /t:build "/p:Configuration=Release" "/p:Platform=Win32"
这篇关于MSBuild:错误 MSB4057:项目中不存在目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!