Bug 54984 - [Linux, OSX] Output directory path is truncated leading to failed builds
Summary: [Linux, OSX] Output directory path is truncated leading to failed builds
Alias: None
Product: Tools
Classification: Mono
Component: msbuild ()
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Ankit Jain
Depends on:
Reported: 2017-04-10 19:10 UTC by Marek Habersack
Modified: 2017-06-23 21:22 UTC (History)
2 users (show)

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

diagnostic build log (79.13 KB, application/x-bzip)
2017-04-10 19:14 UTC, Marek Habersack
Log for the issue in previous comment (12.02 KB, application/x-bzip)
2017-05-18 17:37 UTC, Marek Habersack
Another build log (12.02 KB, application/x-bzip)
2017-05-18 18:09 UTC, Marek Habersack

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:

Description Marek Habersack 2017-04-10 19:10:14 UTC
MSBuild cuts the leading part of path to the output directory, but leaves the / separator at the start. This makes it want to create e.g. `/Debug` directory. The excerpt is from the md-addins build on Linux:

  Copying file from "obj/Debug/net-4.5/GuiUnit.exe" to "../../bin/net_4_5/GuiUnit.exe".
  GuiUnit_NET_4_5 -> /home/grendel/vc/xamarin/md-addins/external/guiunit/bin/net_4_5/GuiUnit.exe
  Copying file from "obj/Debug/net-4.5/GuiUnit.exe.mdb" to "../../bin/net_4_5/GuiUnit.exe.mdb".
  Copying file from "../../bin/Debug/net-4.5/nunitlite.xml" to "../../bin/net_4_5/nunitlite.xml".
Done Building Project "/home/grendel/vc/xamarin/md-addins/external/guiunit/src/framework/GuiUnit_NET_4_5.csproj" (default targets).
  Creating directory "/Debug/".
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(4887,5): error MSB3191: Unable to create directory "/Debug/". Access to the path "/Debug/" is denied. [/home/grendel/vc/xamarin/md-addins/Xamarin.Ide/Xamarin.Ide.Tests/Xamarin.Ide.Tests.csproj]
Done Building Project "/home/grendel/vc/xamarin/md-addins/Xamarin.Ide/Xamarin.Ide.Tests/Xamarin.Ide.Tests.csproj" (default targets) -- FAILED.
Project "/home/grendel/vc/xamarin/md-addins/md-addins.sln" (1) is building "/home/grendel/vc/xamarin/md-addins/Xamarin.Forms.Addin/Xamarin.Forms.Addin.csproj" (26) on node 1 (default targets).
  Creating directory "Packages".
  Copying file from "../packages/Xamarin.Forms." to "Packages/Xamarin.Forms.".
  Copying file from "../packages/Xamarin.Android.Support.v4.23.3.0/Xamarin.Android.Support.v4.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.v4.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.Design.23.3.0/Xamarin.Android.Support.Design.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.Design.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.v7.AppCompat.23.3.0/Xamarin.Android.Support.v7.AppCompat.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.v7.AppCompat.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.v7.CardView.23.3.0/Xamarin.Android.Support.v7.CardView.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.v7.CardView.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.v7.MediaRouter.23.3.0/Xamarin.Android.Support.v7.MediaRouter.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.v7.MediaRouter.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.v7.RecyclerView.23.3.0/Xamarin.Android.Support.v7.RecyclerView.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.v7.RecyclerView.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.Vector.Drawable.23.3.0/Xamarin.Android.Support.Vector.Drawable.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.Vector.Drawable.23.3.0.nupkg".
  Copying file from "../packages/Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0/Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0.nupkg" to "Packages/Xamarin.Android.Support.Animated.Vector.Drawable.23.3.0.nupkg".
  Creating directory "build/".
  Creating directory "/DebugLinux/".
/home/grendel/devel/mono/mono-master/lib/mono/msbuild/15.0/bin/Microsoft.Common.CurrentVersion.targets(1076,5): warning MSB3191: Unable to create directory "/DebugLinux/". Access to the path "/DebugLinux/" is denied. [/home/grendel/vc/xamarin/md-addins/Xamarin.Forms.Addin/Xamarin.Forms.Addin.csproj]
  The previous error was converted to a warning because the task was called with ContinueOnError=true.
  Build continuing because "ContinueOnError" on the task "MakeDir" is set to "True".
Creating directory "/DebugLinux/".
Comment 1 Marek Habersack 2017-04-10 19:14:01 UTC
This is happening with the following versions:

  Mono JIT compiler version 5.1.0 (master/68c053315e2 Thu  6 Apr 14:06:52 CEST 2017)
  Microsoft (R) Build Engine version
Comment 2 Marek Habersack 2017-04-10 19:14:51 UTC
Created attachment 21409 [details]
diagnostic build log
Comment 3 Ankit Jain 2017-04-10 21:02:09 UTC
The attached log is not diagnostic. Could you run msbuild with `/fl /flp:v=diag` and attach the generated msbuild.log?
Comment 4 Marek Habersack 2017-05-18 17:35:30 UTC
I've just seen it happen on OSX too with

   Microsoft (R) Build Engine version (xplat-2017-02/3738dec Tue Apr  4 17:23:12 EDT 2017)
   Mono JIT compiler version (2017-02/dda961c Tue Apr  4 17:07:38 EDT 2017)

while building Xamarin.AndroidSDK.Manager.sln from https://github.com/xamarin/android-sdk-installer

Verbose log will follow
Comment 5 Marek Habersack 2017-05-18 17:37:29 UTC
Created attachment 22280 [details]
Log for the issue in previous comment
Comment 6 Marek Habersack 2017-05-18 18:09:32 UTC
Created attachment 22281 [details]
Another build log

The same happens with

   Mono JIT compiler version (2017-04/8a3993f Thu May 18 09:17:44 EDT 2017)
   Microsoft (R) Build Engine version (d15.3/e5db6a9 Tue May  9 15:02:19 EDT 2017)

but I'm starting to wonder if it's my particular configuration... I have XA in the path, maybe it confuses msbuild somehow? But then, xbuild works fine...
Comment 7 Jonathan Pryor 2017-06-07 19:38:47 UTC
Possibly related: conversation from:


Summary: the behavior described in Comment #0:

> Creating directory "/Debug/"

could be explained by using `msbuild` when overriding the `$MSBuildExtensionsPath` environment variable. When this happens, `Microsoft.Common.props` isn't found/imported, causing the `$(BaseIntermediateOutputPath)` property to be empty. As this is the property which is *normally* `obj`, resulting in e.g. `obj/Debug` for `$(IntermediateOutputPath)`, `$(BaseIntermediateOutputPath)` being empty breaks *everything*.

As confirmation, of sorts, Attachment #22280 [details] doesn't mention `Microsoft.Common.props`. A normal build *should*, e.g.

> Trying to import /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/xbuild/$(MSBuildToolsVersion)/Microsoft.Common.props using extensions path /Library/Frameworks/Mono.framework/Versions/5.2.0/lib/mono/xbuild

Additionally, Attachment #22280 [details] contains:

> Search paths being used for $(MSBuildExtensionsPath) are /Users/grendel/vc/xamarin/monodroid/out/lib/xbuild:/Library/Frameworks/Mono.framework/External/xbuild/

further suggesting that `$MSBuildExtensionsPath` is being overridden.
Comment 8 Marek Habersack 2017-06-23 21:22:22 UTC
Indeed, as @Jonp suggests in comment 7, the reason for this was presence of the MSBuildExtensionsPath in the shell environment while running msbuild. Unsetting the variable makes the build work.