visual-studio Visual Studio 项目中不存在目标“build”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2035414/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Target "build" does not exist in the project for Visual Studio
提问by CountCet
I'm checking out code for a project where contributors use different dev tools for coding in c sharp (C#). My .csproj file was manipulated by someone using Sharp develop and now I get 'The target "build" does not exist in the project'.
我正在检查一个项目的代码,其中贡献者使用不同的开发工具在 cSharp (C#) 中进行编码。我的 .csproj 文件被某人使用 Sharp develop 操纵,现在我得到“项目中不存在目标“构建””。
- How can I correct this?
- 我该如何纠正?
I am using Visual Studio 2008 SP 1.
我正在使用 Visual Studio 2008 SP 1。
采纳答案by Gabriel McAdams
If you were to do it manually, I would take all the files and add them back to a new project file one by one.
如果您要手动进行,我会将所有文件一一添加回新的项目文件中。
回答by Shankar
The accepted answer is a workaround, not a solution. You need to open the .csprojfile for editing in a text editor and ensure the following line is present in there
接受的答案是一种解决方法,而不是解决方案。您需要.csproj在文本编辑器中打开文件进行编辑,并确保其中包含以下行
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
If not add it to the end.
如果没有添加到最后。
Note: For VS2008, this may be $(MSBuildToolsPath)
注意:对于 VS2008,这可能是 $(MSBuildToolsPath)
回答by Shashank
I had the same problem when I upgraded a project built in VS2005 to VS2010 Express. Initially the VS2010 refused to load the project with error message "Project is not supported by this installation". After trying many solutions finally it worked and my guess is it worked when two lines were removed from the project file that related to build target. However it presented a new problem that the project would not build. Of course this makes sense as I removed the entries from project file that told Visual Studio how to build the project.
当我将 VS2005 中构建的项目升级到 VS2010 Express 时,我遇到了同样的问题。最初 VS2010 拒绝加载项目并显示错误消息“此安装不支持项目”。在尝试了许多解决方案后,它终于奏效了,我的猜测是,当从与构建目标相关的项目文件中删除两行时,它就奏效了。然而,它提出了一个新的问题,该项目无法构建。当然,这是有道理的,因为我从项目文件中删除了告诉 Visual Studio 如何构建项目的条目。
Finally got hold of another project that was working on VS2010 Express and copied following lines to the project that was failing. It worked after that.
终于找到了另一个在 VS2010 Express 上工作的项目,并将以下几行复制到失败的项目中。在那之后它起作用了。
<Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
Hope this helps someone.
希望这可以帮助某人。
回答by Efran Cobisi
Just had this issue with Visual Studio 2017 v15.9.2 and wiping out the .vsfolder in the solution root was the only solution that worked for me.
刚刚在 Visual Studio 2017 v15.9.2 上遇到了这个问题,清除.vs解决方案根目录中的文件夹是唯一对我有用的解决方案。
回答by knocte
As for me, I was trying to build a solution with F# projects (.fsproj files).
至于我,我试图用 F# 项目(.fsproj 文件)构建一个解决方案。
The problem was that I was using an old MSBuild (located in path %WINDIR%\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe).
问题是我使用的是旧的 MSBuild(位于 path %WINDIR%\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe)。
When I tried to run the new version, located in "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe", everything started working fine.
当我尝试运行位于 的新版本时"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe",一切都开始正常运行。
Or in case you're using Visual Studio Enterprise, or GithubActions CI, then the path is "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe".
或者,如果您使用的是 Visual Studio Enterprise 或 GithubActions CI,则路径为"%ProgramFiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe".
I found them by running this:
我通过运行这个找到了它们:
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -find MSBuild\**\Bin\MSBuild.exe
回答by user1542334
Deleting the .vs folder worked for me.
删除 .vs 文件夹对我有用。

