Skip to content

HostWriter.CodeSign fails when building .NET 6 preview 7 Angular projects with Visual Studio for Mac. #55992

@mrward

Description

@mrward

Description

Unable to build .NET 6 preview 7 Angular projects with Visual Studio for Mac.

Creating a new .NET 6 Angular project dotnet new angular and then building that with Visual Studio for Mac fails with the error:

Target "_CreateAppHost" in file "/usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets":
  Building target "_CreateAppHost" completely.
  Output file "~/Projects/Tests/dotnet6/test/test/obj/Debug/net6.0/apphost" does not exist.
  Using "CreateAppHost" task from assembly "/usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/../tools/net472/Microsoft.NET.Build.Tasks.dll".
  Task "CreateAppHost"
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018: System.InvalidOperationException: The Process object must have the UseShellExecute property set to false in order to redirect IO streams.
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo) [0x00121] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/System/System.Diagnostics/Process.cs:622 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start () [0x00032] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs:2001 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo) [0x0001b] in /Users/builder/jenkins/workspace/build-package-osx-mono/2020-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/System/services/monitoring/system/diagnosticts/Process.cs:2490 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath) [0x0003b] in <740df77acf124fe2834ec0651d32dc6c>:0 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost (System.String appHostSourceFilePath, System.String appHostDestinationFilePath, System.String appBinaryFilePath, System.Boolean windowsGraphicalUserInterface, System.String assemblyToCopyResorcesFrom, System.Boolean enableMacOSCodeSign) [0x0010d] in <740df77acf124fe2834ec0651d32dc6c>:0 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore () [0x0004e] in <45402358b8b0432b91aec569843553be>:0 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute () [0x0002e] in <45402358b8b0432b91aec569843553be>:0 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute () [0x00023] in /Users/builder/jenkins/workspace/build-package-osx-mono-pullrequest/pr/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/TaskExecutionHost/TaskExecutionHost.cs:578 
    /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask (Microsoft.Build.BackEnd.ITaskExecutionHost taskExecutionHost, Microsoft.Build.BackEnd.Logging.TaskLoggingContext taskLoggingContext, Microsoft.Build.BackEnd.TaskHost taskHost, Microsoft.Build.BackEnd.ItemBucket bucket, Microsoft.Build.BackEnd.TaskExecutionMode howToExecuteTask) [0x002b9] in /Users/builder/jenkins/workspace/build-package-osx-mono-pullrequest/pr/external/bockbuild/builds/msbuild-15/src/Build/BackEnd/Components/RequestBuilder/TaskBuilder.cs:807 
  Done executing task "CreateAppHost" -- FAILED.

A codesign change was added to the runtime recently:

#53913

This HostWriter.CodeSign method runs /usr/bin/codesign and sets RedirectStandardError to true, but does not set UseShellExecute to false.

Visual Studio for Mac runs on Mono. Mono throws an exception due to this check:

https://github.com/mono/mono/blob/78c2b8da29881eccda4c27ca7b2b7e9ed451c55f/mcs/class/System/System.Diagnostics/Process.cs#L593

dotnet itself does not have a problem with the code as it is.

//cc @mateoatr

Configuration

dotnet --info:

dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.100-preview.7.21369.21
 Commit:    d553cd737e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.15
 OS Platform: Darwin
 RID:         osx.10.15-x64
 Base Path:   /usr/local/share/dotnet/sdk/6.0.100-preview.7.21369.21/

Host (useful for support):
  Version: 6.0.0-preview.7.21369.8
  Commit:  71c078d515

.NET SDKs installed:
  6.0.100-preview.7.21369.21 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.0-preview.7.21369.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.0-preview.7.21369.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
  https://aka.ms/dotnet-download

Regression?

I believe this worked in .NET 6 preview 6

Other information

Fix should be to set UseShellExecute to false in the CodeSignmethod.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-HostModelMicrosoft.NET.HostModel issuesuntriagedNew issue has not been triaged by the area owner

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions