Target "build" does not exist in the project for Visual Studio

Visual StudioVisual Studio-2008

Visual Studio Problem Overview


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'.

  • How can I correct this?

I am using Visual Studio 2008 SP 1.

Visual Studio Solutions


Solution 1 - Visual Studio

The accepted answer is a workaround, not a solution. You need to open the .csproj file for editing in a text editor and ensure the following line is present in there

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

If not add it to the end.

Note: For VS2008, this may be $(MSBuildToolsPath)

Solution 2 - Visual Studio

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.

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.

 <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
 <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />

Hope this helps someone.

Solution 3 - Visual Studio

Just had this issue with Visual Studio 2017 v15.9.2 and wiping out the .vs folder in the solution root was the only solution that worked for me.

Solution 4 - Visual Studio

Deleting the .vs folder worked for me.

Solution 5 - Visual Studio

As for me, I was trying to build a solution with F# projects (.fsproj files).

The problem was that I was using an old MSBuild (located in 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.

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".

I found them by running this:

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -find MSBuild\**\Bin\MSBuild.exe

Solution 6 - Visual Studio

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionCountCetView Question on Stackoverflow
Solution 1 - Visual StudioShankarView Answer on Stackoverflow
Solution 2 - Visual StudioShashankView Answer on Stackoverflow
Solution 3 - Visual StudioEfran CobisiView Answer on Stackoverflow
Solution 4 - Visual Studiouser1542334View Answer on Stackoverflow
Solution 5 - Visual StudioknocteView Answer on Stackoverflow
Solution 6 - Visual StudioGabriel McAdamsView Answer on Stackoverflow