Bug 57813 - [VSFeedback Ticket] #445845 - Error The target build does not exist in the project
Summary: [VSFeedback Ticket] #445845 - Error The target build does not exist in the pr...
Status: CONFIRMED
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: 5.4 (2017-06)
Hardware: PC Mac OS
: Normal normal
Target Milestone: Future Cycle (TBD)
Assignee: Ankit Jain
URL:
Depends on:
Blocks:
 
Reported: 2017-06-27 21:29 UTC by Ashley Gazich [MSFT]
Modified: 2018-01-11 15:22 UTC (History)
4 users (show)

Tags: VSDCItem
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 57813 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Ashley Gazich [MSFT] 2017-06-27 21:29:34 UTC
VSTS ticket https://devdiv.visualstudio.com/DevDiv/_workitems/edit/445845

How to fix this error? 
The target "Build" does not exist in the project. (MSB4057)
https://developercommunity.visualstudio.com/storage/attachments/6749-photo.jpg

New blank project from template also fails to build on Version 7.1 Preview (7.1 build 583).
Comment 1 Matt Ward 2017-07-07 18:27:37 UTC
If you go into project options - Build - General and uncheck Use MSBuild Engine then the project will compile. Compiling with xbuild or msbuild fail with the error about the missing "Build" target.

Building from the command line with msbuild it seems as though no VisualBasic .targets files are loaded for some reason.
Comment 2 Ankit Jain 2017-07-12 15:44:57 UTC
VBNet projects being generated from the templates are missing:

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

This shouldn't build with msbuild or xbuild.
Comment 3 Matt Ward 2017-07-12 15:51:47 UTC
Sounds like the project templates need fixing.
Comment 4 Ashley Gazich [MSFT] 2017-09-06 15:12:36 UTC
Another report https://devdiv.visualstudio.com/DevDiv/_workitems/edit/490333
Comment 5 Matt Ward 2017-09-06 16:08:24 UTC
Adding the Import specified in Comment #2 does not fix the build. With Mono 5.4.0.167 (2017-06/6b8abfeb7cc Thu Aug 17 18:17:27 EDT 2017) and the Microsoft.VisualBasic.targets file imported the build error you see is:

/Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/msbuild/15.0/bin/Roslyn/Microsoft.VisualBasic.Core.targets(5,5): Error MSB6004: The specified task executable location "/Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/msbuild/15.0/bin/Roslyn/vbnc.exe" is invalid. (MSB6004)

In that directory there is a vbc.exe not a vbnc.exe. Looking at the MSBuild diagnostic output:

_VbcToolExeTmp = vbnc.exe
VbcToolExe = vbnc.exe

A grep through the Mono directory:

./15.0/bin/Microsoft.VisualBasic.CurrentVersion.targets:              ToolExe="$(VbcToolExe)"
./15.0/bin/Microsoft.VisualBasic.Mono.targets:        <_VbcToolExeTmp Condition="'$(VbcToolExe)' != ''">$(VbcToolExe)</_VbcToolExeTmp>
./15.0/bin/Microsoft.VisualBasic.Mono.targets:        <_VbcToolExeTmp Condition="'$(_VbcToolExeTmp)' == '' and '$(MSBuildRuntimeType)' == 'Mono'">vbnc.exe</_VbcToolExeTmp>
./15.0/bin/Microsoft.VisualBasic.Mono.targets:        <VbcDebugFileExt Condition="'$(VbcDebugFileExt)' == '' and ('$(_VbcToolExeTmp)' == 'vbnc' or '$(_VbcToolExeTmp)' == 'vbnc.exe')">.mdb</VbcDebugFileExt>
./15.0/bin/Microsoft.VisualBasic.Mono.targets:        <VbcToolExe Condition="'$(VbcToolExe)' == '' and '$(MSBuildRuntimeType)' == 'Mono'">vbnc.exe</VbcToolExe>

If you try to run vbc.exe that fails with an exception:

    System.TypeInitializationException: The type initializer for 'Microsoft.CodeAnalysis.VisualBasic.VisualBasicCommandLineParser' threw an exception. ---> System.TypeLoadException: Could not resolve type with token 01000286 (from typeref, class/assembly Roslyn.Utilities.IObjectReadable, Microsoft.CodeAnalysis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)


VS on Windows uses MSBuildToolsPath instead of MSBuildBinPath however the build error is the same:

<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />