我一直在尝试在本地的visual studio 2017社区上构建一个.NET项目。
使用Publish
选项完成构建时运行良好,但尝试使用msbuild
时抛出以下错误
C:Usersajay3sourcereposTriyo.APITriyoCore.API>msbuild
Microsoft (R) Build Engine version 4.8.4084.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.
Build started 2021-06-28 3:55:47 PM.
Project "C:Usersajay3sourcereposTriyo.APITriyoCore.APITriyoCore.API.csproj" on node 1 (default targets).
C:Usersajay3sourcereposTriyo.APITriyoCore.APITriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:Program Files (x86)MSBuildMicrosoftVisualSt
udio**v11.0**WebApplicationsMicrosoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.
Done Building Project "C:Usersajay3sourcereposTriyo.APITriyoCore.APITriyoCore.API.csproj" (default targets) -- FAILED.
Build FAILED.
"C:Usersajay3sourcereposTriyo.APITriyoCore.APITriyoCore.API.csproj" (default target) (1) ->
C:Usersajay3sourcereposTriyo.APITriyoCore.APITriyoCore.API.csproj(281,3): error MSB4019: The imported project "C:Program Files (x86)MSBuildMicrosoftVisual
Studio**v11.0**WebApplicationsMicrosoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on
disk.
0 Warning(s)
1 Error(s)
Time Elapsed 00:00:00.08
我在Stackoverflow和其他网站上看过各种类似的文章,但都没有帮助。
它从哪里推出v11.0?我的csproj
文件中没有该值。
您使用的是正确版本的MSBuild
吗?
C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe
C:WindowsMicrosoft.NETFrameworkv2.0.50727MSBuild.exe
C:WindowsMicrosoft.NETFramework64v4.0.30319MSBuild.exe
C:WindowsMicrosoft.NETFramework64v2.0.50727MSBuild.exe
MSBuild
的路径可能会有所不同,具体取决于您的电脑
如果Yes
检查以下示例
C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe C:Usersajay3sourcereposTriyo.APITriyoCore.APITriyoCore.API.csproj /t:Clean
有关更多信息,请运行以下命令:
C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe /?
你也可以使用这个链接
我清理了我的系统并重新安装了msbuild,现在它工作得很好。