msbuild: [BUG] MSBuildWorkspace.Create() - Exception on mac

Update

Scroll down to see a workaround https://github.com/Microsoft/msbuild/issues/1469#issuecomment-287585930

But I still consider this a bug and it would be nice if it would work out of the box


Steps to recreate

Machine: Mac, macOS Sierra, Xamarin 6.1.2

  • Create new project
  • Target Framework: .NET 4.6.1
  • Install packages:
    • Microsoft.Net.Compilers
    • Microsoft.CodeAnalysis
    • Microsoft.Build 15.1.0-preview-000370-00 // required to make MSBuildWorkspace.Create() work on a mac
    • Microsoft.Build.Tasks.Core.15.1.0-preview-000370-00
  • Change configuration to Release, otherwise: CSC: error CS0041: Unexpected error writing debug information -- 'Windows PDB writer is not available -- could not find Microsoft.DiaSymReader.Native.x86.dll' Task "Csc" execution -- FAILED Done building target "CoreCompile" in project "/Users/sschmid/Desktop/MSBuildBug/MSBuildBug/MSBuildBug.csproj".-- FAILED
  • Open a project
var project = workspace.OpenProjectAsync(path).Result;

Expected Behaviour

Open a project

Actual Behaviour

Exception thrown:

[ERROR] FATAL UNHANDLED EXCEPTION: System.AggregateException: One or more errors occurred. ---> System.TypeLoadException: Could not load type 'Microsoft.Build.BackEnd.Logging.LoggingService' from assembly 'Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
  at Microsoft.Build.Evaluation.ProjectCollection..ctor (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.Collections.Generic.IEnumerable`1[T] loggers, System.Collections.Generic.IEnumerable`1[T] remoteLoggers, Microsoft.Build.Evaluation.ToolsetDefinitionLocations toolsetDefinitionLocations, System.Int32 maxNodeCount, System.Boolean onlyLogCriticalEvents) [0x00047] in <c29aeb497bfe46008f6d9d90f46bebf9>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143 
  at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00047] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 
  at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x0002e] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 
  at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x0000b] in /private/tmp/source-mono-4.6.0/bockbuild-mono-4.6.0-branch/profiles/mono-mac-xamarin/build-root/mono-x86/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 
  at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <8f2c484307284b51944a1a13a14c0266>:0 
  at Microsoft.CodeAnalysis.MSBuild.ProjectFileLoader+<LoadProjectFileAsync>d__3.MoveNext () [0x00089] in <2ba3a08d4fe0467c8c54c8bc37c61987>:0 

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 1
  • Comments: 24 (7 by maintainers)

Commits related to this issue

Most upvoted comments

@KirillOsenkov I’m happy too

From a user perspective I’d say it’s a bug. The documentation only mentions Microsoft.Net.Compilers and Microsoft.CodeAnalysis.

2 missing steps:

@KirillOsenkov Added Microsoft.VisualStudio.RemoteControl. MSBuildWorkspace.Create() works now! Yay 😃