更新到 VS 2019 16.10.0 后 MSBuild 错误 MSB4057
MSBuild error MSB4057 after updating to VS 2019 16.10.0
在更新到 VS 2019 16.10.0 之前,以下命令完美运行:
msbuild.exe MySolution.sln /t:Project1;Project2;Project3 /p:Configuration=Release /p:DebugType=None /p:OutputPath="C:\Users\myuser\Desktop\Build"
更新后我收到消息错误 MSB4057:项目中不存在目标“Project1” 当我在 VS 2019 的开发人员命令提示符中尝试命令时.
在 Microsoft 发布更新之前,我们发现您可以将 :Rebuild 添加到您的项目的末尾并为我们修复它。
msbuild.exe MySolution.sln /t:Project1:Rebuild;Project2:Rebuild;Project3:Rebuild /p:Configuration=Release /p:DebugType=None /p:OutputPath="C:\Users\myuser\Desktop\Build"
作为替代方案,如果您想避免接受的答案建议的重建:
- 向项目文件添加自定义目标,如
<Target Name="MyBuild" DependsOnTargets="Build" />
- 从脚本中调用这个目标,例如
msbuild.exe MySolution.sln /t:Project1:MyBuild;Project2:MyBuild;Project3:MyBuild /p:Configuration=Release /p:DebugType=None /p:OutputPath="C:\Users\myuser\Desktop\Build"
在更新到 VS 2019 16.10.0 之前,以下命令完美运行:
msbuild.exe MySolution.sln /t:Project1;Project2;Project3 /p:Configuration=Release /p:DebugType=None /p:OutputPath="C:\Users\myuser\Desktop\Build"
更新后我收到消息错误 MSB4057:项目中不存在目标“Project1” 当我在 VS 2019 的开发人员命令提示符中尝试命令时.
在 Microsoft 发布更新之前,我们发现您可以将 :Rebuild 添加到您的项目的末尾并为我们修复它。
msbuild.exe MySolution.sln /t:Project1:Rebuild;Project2:Rebuild;Project3:Rebuild /p:Configuration=Release /p:DebugType=None /p:OutputPath="C:\Users\myuser\Desktop\Build"
作为替代方案,如果您想避免接受的答案建议的重建:
- 向项目文件添加自定义目标,如
<Target Name="MyBuild" DependsOnTargets="Build" />
- 从脚本中调用这个目标,例如
msbuild.exe MySolution.sln /t:Project1:MyBuild;Project2:MyBuild;Project3:MyBuild /p:Configuration=Release /p:DebugType=None /p:OutputPath="C:\Users\myuser\Desktop\Build"