Bug 23555 - Build fails when a \ character is in the code with "Error: Unknown MSBuild failure. Please try building the project again."
Summary: Build fails when a \ character is in the code with "Error: Unknown MSBuild fa...
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Tools
Classification: Mono
Component: xbuild ()
Version: unspecified
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-10-02 13:39 UTC by Kent Green [MSFT]
Modified: 2017-03-20 18:45 UTC (History)
6 users (show)

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


Attachments
Sample to reproduce the bug & Log folder (821.53 KB, application/zip)
2014-10-02 13:39 UTC, Kent Green [MSFT]
Details


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 on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NOT_REPRODUCIBLE

Description Kent Green [MSFT] 2014-10-02 13:39:07 UTC
Created attachment 8289 [details]
Sample to reproduce the bug & Log folder

--Overview:--
From this desk case:
https://xamarin.desk.com/agent/case/90710

The customer was unable to build with the only error message given being "Error: Unknown MSBuild failure. Please try building again." Though building again didn't change the result.

Clicking on the error message takes the user to the first line of the given project's .csproj file, incorrectly implying the error is there. 

--To reproduce the error:--
1) Create a new project (for my tests I used an Android application, though I suspect it might occur on other projects as well.)
2) Insert a '\' character after the usings commands. (Also might occur elsewhere but this is the main place I tested).

Example:
using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

//TODO: the backslash character below causes the Unknown MSBuild failure error. 
\

--Workaround--
It is worth noting that the Intellisense does highlight the character in red, and provides the mouseover text:
"Parser Error: Unrecognized Escape Sequence '\'"

Because the error isn't found automatically though, in large projects it can be difficult to determine where the issue is occurring, unless you observe it directly; since the error message takes the user to look at the .csproj file instead of the actual location of the typo.

--Build Information--
In my tests I could repo in both Stable and Beta channels, but only on Mac; PC version seems to have the correct behavior.

=== Xamarin Studio ===

Version 5.5 (build 225)
Installation UUID: 8ef63a7c-1b18-40de-a334-7f78777fcb55
Runtime:
	Mono 3.10.0 ((detached/47db868)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 310000019

=== Apple Developer Tools ===

Xcode 6.0.1 (6528)
Build 6A317

=== Xamarin.iOS ===

Version: 8.2.0.191 (Business Edition)
Hash: ff9d4a0
Branch: 
Build date: 2014-10-01 01:14:53-0400

=== Xamarin.Android ===

Version: 4.18.0 (Business Edition)
Android SDK: /Users/kentgreen/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		2.1   (API level 7)
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.3   (API level 18)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

=== Xamarin.Mac ===

Version: 1.10.0.18 (Business Edition)

=== Build Information ===

Release ID: 505000225
Git revision: 50a525f6fca1b6ad5bd4da1ab2f2b0083240826d
Build date: 2014-09-30 12:07:18-04
Xamarin addins: bcebe330d7d264c5241c3d9b459aaf3bfd8ac4e0

=== Operating System ===

Mac OS X 10.9.4
Darwin Kents-MacBook-Pro.local 13.3.0 Darwin Kernel Version 13.3.0
    Tue Jun  3 21:27:35 PDT 2014
    root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
Comment 1 Rajneesh Kumar 2014-10-03 02:00:21 UTC
I have checked this issue and able to reproduce. To reproduce this issue I have followed the instruction and steps provided in bug description.

Step I have followed:

1. Create an android application in XS
2. Insert a '\' character after the usings commands.
3. Hover '\' it will show  "Parser Error: Unrecognized Escape Sequence '\'"
4. Build the application the backslash character below causes the Unknown MSBuild failure error. 
5. Click on error message showing in Errors
5. Observe that, the error message takes the user to look at the .csproj file instead of the actual location   of  the typo.

Screencast: http://www.screencast.com/t/v2YkQOYQl0

Environment Info:

=== Xamarin Studio ===

Version 5.4 (build 240)
Installation UUID: 011d70a5-dede-428b-ab04-ef451c2e539d
Runtime:
	Mono 3.8.0 ((no/db71bc1)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 308000013

=== Xamarin.Android ===

Version: 4.16.0 (Enterprise Edition)
Android SDK: /Users/MM/Desktop/android-sdk-macosx
	Supported Android versions:
		2.1    (API level 7)
		2.2    (API level 8)
		2.3    (API level 10)
		3.1    (API level 12)
		3.2    (API level 13)
		4.0    (API level 14)
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		4.5    (API level 21)
Java SDK: /usr
java version "1.7.0_65"
Java(TM) SE Runtime Environment (build 1.7.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)

=== Apple Developer Tools ===

Xcode 5.1 (5084)
Build 5B130a

=== Xamarin.iOS ===

Version: 8.0.0.63 (Enterprise Edition)
Hash: 58b46df
Branch: 
Build date: 2014-09-18 22:32:07-0400

=== Xamarin.Mac ===

Version: 1.10.0.13 (Starter Edition)

=== Build Information ===

Release ID: 504000240
Git revision: 01786bc67c7024ec33d327ed27e4416d7a846f4e
Build date: 2014-09-17 10:58:48-04
Xamarin addins: 7cd7dfcd6b7b7b53281508954ec080f1cd153ad3

=== Operating System ===

Mac OS X 10.9.5
Darwin MacMini.local 13.4.0 Darwin Kernel Version 13.4.0
    Sun Aug 17 19:50:11 PDT 2014
    root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64
Comment 2 Jonathan Pryor 2014-12-18 17:00:57 UTC
This isn't a Xamarin.Android bug. This is an `xbuild` bug.

If you run `xbuild` from the command line, it generates an mcs error about the Unrecognized escape sequence...the blows up within Microsoft.Build.Utilities.MSBuildErrorParser.TryParseLine():

> MainActivity.cs(10,1): error CS1009: Unrecognized escape sequence `\
> 
> Unhandled Exception:
> System.ArgumentOutOfRangeException: startIndex > this.length
> Parameter name: startIndex
>   at System.String.IndexOf (Char value, Int32 startIndex) [0x00052] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/corlib/System/String.cs:1203 
>   at Microsoft.Build.Utilities.MSBuildErrorParser.TryParseLine (System.String line) [0x00010] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/MSBuildErrorParser.cs:69 
>   at Microsoft.Build.Utilities.ToolTask.LogEventsFromTextOutput (System.String singleLine, MessageImportance messageImportance) [0x0008f] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs:290 
>   at Microsoft.Build.Utilities.ToolTask.ProcessLine (System.Text.StringBuilder outputBuilder, System.String line, MessageImportance importance) [0x0007b] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs:267 
>   at Microsoft.Build.Utilities.ToolTask+<ExecuteTool>c__AnonStorey0.<>m__1 (System.Object _, System.String msg) [0x00000] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ToolTask.cs:180 
>   at Microsoft.Build.Utilities.ProcessWrapper.CaptureError () [0x0001b] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/Microsoft.Build.Utilities/Microsoft.Build.Utilities/ProcessWrapper.cs:87 
>   at System.Threading.Thread.StartInternal () [0x00016] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/corlib/System.Threading/Thread.cs:691 

The actual mcs output is:

> MainActivity.cs(10,1): error CS1009: Unrecognized escape sequence `\
> '
> MainActivity.cs(10,0): error CS1525: Unexpected symbol `
> '
> Compilation failed: 2 error(s), 0 warnings
Comment 3 Kent Green [MSFT] 2017-03-20 18:45:13 UTC
This issue is no longer reproducible in the current stable version of Xamarin Studio. Version information where I confirmed this:

=== Xamarin Studio Community ===

Version 6.3 (build 834)
Installation UUID: 8ef63a7c-1b18-40de-a334-7f78777fcb55
Runtime:
	Mono 4.8.0 (mono-4.8.0-branch/8f6d0f6) (64-bit)
	GTK+ 2.24.23 (Raleigh theme)

	Package version: 408000520

=== NuGet ===

Version: 3.5.0.0

=== Xamarin.Profiler ===

Version: 1.3.3
Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

=== Apple Developer Tools ===

Xcode 8.2.1 (11766.1)
Build 8C1002

=== Xamarin.Mac ===

Version: 3.2.0.20 (Xamarin Studio Community)

=== Xamarin.Android ===

Version: 7.2.0.2 (Xamarin Studio Community)
Android SDK: /Users/kentgreen/Library/Developer/Xamarin/android-sdk-macosx
	Supported Android versions:
		4.0.3  (API level 15)
		4.1    (API level 16)
		4.2    (API level 17)
		4.3    (API level 18)
		4.4    (API level 19)
		4.4.87 (API level 20)
		5.0    (API level 21)
		5.1    (API level 22)
		6.0    (API level 23)
		7.0    (API level 24)
		7.1    (API level 25)

SDK Tools Version: 25.2.4
SDK Platform Tools Version: 25.0.3
SDK Build Tools Version: 25.0.2

Java SDK: /usr
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)

Android Designer EPL code available here:
https://github.com/xamarin/AndroidDesigner.EPL

=== Xamarin Inspector ===

Not Installed

=== Xamarin.iOS ===

Version: 10.8.0.20 (Xamarin Studio Community)
Hash: f94cf26
Branch: d15-1
Build date: 2017-03-14 12:37:51-0400

=== Xamarin Inspector ===

Version: 0.7.1.0
Hash: 545e74c
Branch: master
Build date: Fri Apr  8 17:34:53 UTC 2016

=== Build Information ===

Release ID: 603000834
Git revision: bb1dff522ee38d9963b4d97f6cfa0f92c85e8ecb
Build date: 2017-03-14 13:38:37-04
Xamarin addins: 8aac7919dc66c1ce0d9d75fe150ddc1ab15fd941
Build lane: monodevelop-lion-d15-1

=== Operating System ===

Mac OS X 10.12.3
Darwin Kents-MBP 16.4.0 Darwin Kernel Version 16.4.0
    Thu Dec 22 22:53:21 PST 2016
    root:xnu-3789.41.3~3/RELEASE_X86_64 x86_64

=== Enabled user installed addins ===

Xamarin Inspector 0.7.1.0