Bug 52797 - MSBuild is not correctly provided with mono-complete on linux (OSX and Win is fine)
Summary: MSBuild is not correctly provided with mono-complete on linux (OSX and Win is...
Status: RESOLVED DOWNSTREAM
Alias: None
Product: Installers
Classification: Mono
Component: General ()
Version: 4.8.0 (C9)
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Jo Shields
URL:
Depends on:
Blocks:
 
Reported: 2017-02-25 10:00 UTC by Terry Drever
Modified: 2017-03-29 07:12 UTC (History)
2 users (show)

Tags:
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 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 DOWNSTREAM

Description Terry Drever 2017-02-25 10:00:04 UTC
When using the provided mono-complete packages on ubuntu (and presumably other linux based platforms) mono is preferring xbuild over msbuild.
When using the provided mono packages on Windows and OSX mono is preferring msbuild over xbuild. 

Further to this, the version of msbuild that seems to be installed with mono is targeting OSX libraries.

I've been able to replicate this whilst using nuget, specifically the nuget pack command. Please note, there is an issue about this over on the github nuget page, here : https://github.com/NuGet/Home/issues/1946

Example reproduction....

Ubuntu with a fresh install of mono-complete (4.8.0) and the provided xbuild
nuget pack aProject.csproj -verbosity detailed

example output : 
System.NotImplementedException: The method or operation is not implemented.
  at (wrapper dynamic-method) System.Object:CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object)
  at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0] (System.Runtime.CompilerServices.CallSite site, T0 arg0) [0x0011d] in <2392cff65f724abaaed9de072f62bc4a>:0 
  at NuGet.CommandLine.ProjectFactory.ResolveTargetPath () [0x00345] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.ProjectFactory.BuildProject () [0x0016e] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.ProjectFactory.CreateBuilder (System.String basePath, NuGet.Versioning.NuGetVersion version, System.String suffix, System.Boolean buildIfNeeded) [0x0000d] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.Commands.PackCommandRunner.BuildFromProjectFile (System.String path) [0x00123] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.Commands.PackCommandRunner.BuildPackage (System.String path) [0x00033] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.Commands.PackCommandRunner.BuildPackage () [0x00021] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.PackCommand.ExecuteCommand () [0x001f8] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.Command.ExecuteCommandAsync () [0x00000] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.Command.Execute () [0x000b7] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.Program.MainCore (System.String workingDirectory, System.String[] args) [0x001f8] in <dac647f5255f4f14a29ff0994941da2f>:0 



Ubuntu with a fresh install of mono-complete (4.8.0) and the provided msbuild
nuget pack aProject.csproj -verbosity detailed -MSBuildVersion 14.1

example output:
System.IO.FileNotFoundException: Could not load file or assembly '/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/14.1/bin/Microsoft.Build.dll' or one of its dependencies
File name: '/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/14.1/bin/Microsoft.Build.dll'
  at (wrapper managed-to-native) System.Reflection.Assembly:LoadFrom (string,bool)
  at System.Reflection.Assembly.LoadFrom (System.String assemblyFile, System.Security.Policy.Evidence securityEvidence) [0x00000] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Reflection.Assembly.LoadFile (System.String path, System.Security.Policy.Evidence securityEvidence) [0x00031] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at System.Reflection.Assembly.LoadFile (System.String path) [0x00000] in <f712f98eb8e445c8918edaf595bbe465>:0 
  at NuGet.Common.MSBuildUser.LoadAssemblies (System.String msbuildDirectory) [0x00029] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.ProjectFactory..ctor (System.String msbuildDirectory, System.String path, System.Collections.Generic.IDictionary`2[TKey,TValue] projectProperties) [0x00016] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.ProjectFactory.ProjectCreator (NuGet.Commands.PackArgs packArgs, System.String path) [0x00012] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.Commands.PackCommandRunner.BuildFromProjectFile (System.String path) [0x0003c] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.Commands.PackCommandRunner.BuildPackage (System.String path) [0x00033] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.Commands.PackCommandRunner.BuildPackage () [0x00021] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.PackCommand.ExecuteCommand () [0x001f8] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.Command.ExecuteCommandAsync () [0x00000] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.Command.Execute () [0x000b7] in <dac647f5255f4f14a29ff0994941da2f>:0 
  at NuGet.CommandLine.Program.MainCore (System.String workingDirectory, System.String[] args) [0x001f8] in <dac647f5255f4f14a29ff0994941da2f>:0 


Passing MSBuildVersion 14.1, you can see that we're using msbuild as expected but that the binaries that we're attempting to load are from an OSX installation.


Please note, I can install msbuild manually (latest version 15.0) with ubuntu's package manager, and I'd be more than happy to tell mono to use this version of msbuild, if it was possible. The ideal solution however would be that all platforms would use msbuild, since it's readily available on all platforms now. This is actually the final step in me making my build tools platform agnostic and would love to be able to jump over this final hurdle and not have to revert to a windows or OS X box.
Comment 1 Rodrigo Kumpera 2017-02-27 18:20:05 UTC
Hi Jo,

This is a packaging issue, assigning to you.
Comment 2 Jo Shields 2017-02-28 11:50:11 UTC
This is two different issues, conflated.

`msbuild` is not installed by `mono-complete` because `mono-complete` is a "complete" install of everything from mono/mono.git - and msbuild is not part of mono.git in any stable release. There is a distinct `msbuild` package, built from mono/msbuild.git

As to the library path issue, this is hardcoded in NuGet 3 to always assume Mono == Mac - see src/NuGet.Clients/NuGet.CommandLine/Common/CommandLineConstants.cs L13-15 and src/NuGet.Clients/NuGet.CommandLine/MsBuildUtility.cs L482-508 in nuget/nuget.client.git

I don't think this is a big job to fix - but it's their job since they're the ones forcing a bad path. `msbuild` debs/rpms install to /usr/lib/mono/msbuild/15.0/, and FlatPak (where /.flatpak-info exists) to /app/lib/mono/msbuild/15.0/.
Comment 3 Terry Drever 2017-03-29 07:12:44 UTC
Thanks for the feedback Jo Shields, I'll open a ticket over on their end and cross reference this issue. If it's really that simple to fix, I might also attempt to fix it myself and offer up a pull request.