Skip to content

[macOS] Build fails when invoked from the Log Viewer, but works fine in terminal #952

@snechaev

Description

@snechaev

Note: you need the latest .net runtime (10.0.8), SDK (10.0.300) macos workload (26.5.10280/10.0.100) to reproduce this:

I'm trying to build the empty (from the default template) macOS application (net10.0-macos) with the Log Viewer and got the following build error:

  Launching task "ComputeManagedAssemblies" from assembly "/Users/sergey/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/../tools/net/ILLink.Tasks.dll" in an external task host with a runtime of "NET" and a process architecture of "arm64". (TaskId:123)
/Users/sergey/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/Microsoft.NET.ILLink.targets(325,5): error MSB4221: Could not run the "ComputeManagedAssemblies" task because MSBuild could not create or connect to a task host with runtime "NET" and architecture "arm64".  Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "/usr/local/share/dotnet/sdk/10.0.300/MSBuild" exists and can be run. Error  DOTNET_HOST_PATH is not set. Cannot determine runtime location for app host bootstrap. This should always be set when running under the .NET SDK.. [/private/var/folders/80/ktfy98gs02nbn2wb2w5wdk3w0000gn/T/MSBuildTargetsTests_9322d24dec104a4bb5d17cace6e07e2b/TestMacGuiApp.csproj]
/Users/sergey/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/Microsoft.NET.ILLink.targets(326,7): error MSB4027: The "ComputeManagedAssemblies" task generated invalid items from the "ManagedAssemblies" output parameter. This object is no longer valid because the MetadataLoadContext that created it has been disposed. [/private/var/folders/80/ktfy98gs02nbn2wb2w5wdk3w0000gn/T/MSBuildTargetsTests_9322d24dec104a4bb5d17cace6e07e2b/TestMacGuiApp.csproj]
Done executing task "ComputeManagedAssemblies" -- FAILED. (TaskId:123)
Done building target "_ComputeManagedAssemblyToLink" in project "TestMacGuiApp.csproj" -- FAILED.: (TargetId:253)

The same thing with the manual word wrap:

Launching task "ComputeManagedAssemblies" from assembly 
    "/Users/sergey/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/../tools/net/ILLink.Tasks.dll" in an external task
    host with a runtime of "NET" and a process architecture of "arm64". (TaskId:123)
/Users/sergey/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/Microsoft.NET.ILLink.targets(325,5): error MSB4221:
    Could not run the "ComputeManagedAssemblies" task because MSBuild could not create or connect to a task host with
    runtime "NET" and architecture "arm64".  Please ensure that (1) the requested runtime and/or architecture are available
    on the machine, and (2) that the required executable "/usr/local/share/dotnet/sdk/10.0.300/MSBuild" exists and can be run.
    Error  DOTNET_HOST_PATH is not set. Cannot determine runtime location for app host bootstrap. This should always be
    set when running under the .NET SDK.. [/private/var/folders/80/ktfy98gs02nbn2wb2w5wdk3w0000gn/T/MSBuildTargetsTests_9322d24dec104a4bb5d17cace6e07e2b/TestMacGuiApp.csproj]
/Users/sergey/.nuget/packages/microsoft.net.illink.tasks/10.0.8/build/Microsoft.NET.ILLink.targets(326,7): error MSB4027:
    The "ComputeManagedAssemblies" task generated invalid items from the "ManagedAssemblies" output parameter. 
    This object is no longer valid because the MetadataLoadContext that created it has been disposed.
[/private/var/folders/80/ktfy98gs02nbn2wb2w5wdk3w0000gn/T/MSBuildTargetsTests_9322d24dec104a4bb5d17cace6e07e2b/TestMacGuiApp.csproj]
Done executing task "ComputeManagedAssemblies" -- FAILED. (TaskId:123)
Done building target "_ComputeManagedAssemblyToLink" in project "TestMacGuiApp.csproj" -- FAILED.: (TargetId:253)

The same project can be built just fine with simple dotnet build in the console.

To be more specific:

  • the following works fine:
     dotnet build ./TestMacGuiApp.csproj /t:Build /p:Configuration=Debug /v:diag /nologo /clp:NoSummary;Verbosity=minimal
    
  • the following fails (and this command line is used by the Log Viewer to run the build)
    dotnet /usr/local/share/dotnet/sdk/10.0.300/MSBuild.dll ./TestMacGuiApp.csproj  /t:Build /p:Configuration=Debug /v:diag /nologo /clp:NoSummary;Verbosity=minimal
    

The only difference is that in the "good" case we use build term and do not specify MSBuild.dll path; and in the "bad" case we do not use build term and pass the exact path to MSBuild.dll.
As far I can see, that the sameMSBuild.dll is used internally in both cases as I have only one net10 runtime and SDK version installed.

Environment information:

$ uname -a
Darwin Sergeys-Mini.home 25.5.0 Darwin Kernel Version 25.5.0: Mon Apr 27 20:40:51 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T8112 arm64
---------------------------------------------------------------------------------------------------------------------------------------------
$ dotnet --list-sdks
6.0.425 [/usr/local/share/dotnet/sdk]
7.0.410 [/usr/local/share/dotnet/sdk]
8.0.401 [/usr/local/share/dotnet/sdk]
8.0.419 [/usr/local/share/dotnet/sdk]
9.0.203 [/usr/local/share/dotnet/sdk]
10.0.300 [/usr/local/share/dotnet/sdk]

$ dotnet workload list

Workload version: 10.0.300.2

Installed Workload Id      Manifest Version         Installation Source
-----------------------------------------------------------------------
macos                      26.5.10280/10.0.100      SDK 10.0.300

Use `dotnet workload search` to find additional workloads to install.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

$ dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.33 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.25 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.4 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.10 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.33 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.22 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.25 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.10 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

As a test I tried to set the DOTNET_HOST_PATH=/usr/local/share/dotnet/dotnet for the Log Viewer process and this fixed the problem, but this does not feels like a production-ready solution.

And finally I'm not entirely sure where the problem is. Is it a Log Viewer problem as it runs build in the unexpected way (using explicit MSBuild.dll specification instead of the build term)? Or this is .net SDK problem as they broken path resolution logic or something like this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions