Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mrward opened this issue Jul 20, 2021 · 3 comments · Fixed by #56010
Labels
area-HostModel Microsoft.NET.HostModel issues untriaged New issue has not been triaged by the area owner

Comments

@mrward
Copy link

mrward commented Jul 20, 2021

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.

@dotnet-issue-labeler dotnet-issue-labeler bot added area-HostModel Microsoft.NET.HostModel issues untriaged New issue has not been triaged by the area owner labels Jul 20, 2021
@ghost
Copy link

ghost commented Jul 20, 2021

Tagging subscribers to this area: @vitek-karas, @agocke
See info in area-owners.md if you want to be subscribed.

Issue Details

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.

Author: mrward
Assignees: -
Labels:

area-HostModel, untriaged

Milestone: -

@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jul 20, 2021
@mateoatr
Copy link
Contributor

Thanks. I thought this always defaulted to false (I guess not in mono?). Just put a PR.

@mrward
Copy link
Author

mrward commented Jul 20, 2021

It seems to be true by default in Mono and on Windows (full .NET framework).

@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jul 20, 2021
jonpryor added a commit to jonpryor/java.interop that referenced this issue Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on dotnet#865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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.21379.14/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.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False in the "offending" projects.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jonpryor added a commit to jonpryor/java.interop that referenced this issue Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on dotnet#865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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.21379.14/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.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
jonpryor added a commit to dotnet/java-interop that referenced this issue Aug 19, 2021
Context: dotnet/roslyn#55564
Context: https://discord.com/channels/732297728826277939/732297837953679412/874959446747533323
Context: dotnet/runtime#55992
Context: dotnet/sdk#19653 (comment)

Fix the Java.Interop build when .NET 6 Preview 7 is installed.

.NET 6 Preview 7 introduced a C# compiler regression: use of
[C#6 string interpolation][0] with `StringBuilder.Append()` when
`$(LangVersion)` < 10.0 results in a CS8400 error:

	error CS8400: Feature 'interpolated string handlers' is not available in C# 8.0. Please use language version 10.0 or greater.

Because `azure-pipelines.yaml` specifies `DotNetCoreVersion: 6.0.x`,
our CI machines get auto-bumped to .NET 6 Preview 7, causing *all*
PR builds to now fail with this CS8400 failure.

There are two possible solutions:

 1. *Avoid* .NET 6 Preview 7.
 2. Remove select use of string interpolation.

(1) was initially done on #865, by using:

	DotNetCoreVersion: 6.0.100-preview.6.21355.2

However, it's not *all* use of string interpolation which triggers
the CS8400 error.  It's just use of string interpolation within
`StringBuilder.Append()` calls, in 3 locations.

Update `RegisterAttr.cs` to use a `(string)` cast with the existing
string interpolation use.  This works around the CS8400 error.

*Additionally*, macOS+Mono builds would fail in `make all` when
.NET 6 Preview 7 is present:

	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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.21379.14/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.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.StartWithShellExecuteEx (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at System.Diagnostics.Process.Start (System.Diagnostics.ProcessStartInfo startInfo)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.HostModel.AppHost.HostWriter.CodeSign (System.String appHostPath)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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)
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.NET.Build.Tasks.TaskBase.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(536,5): error MSB4018:   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute ()
	/usr/local/share/dotnet/sdk/6.0.100-preview.7.21379.14/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)

This was filed as dotnet/runtime#55992, and can be worked around by
setting `$(UseAppHost)`=False.

[0]: https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-HostModel Microsoft.NET.HostModel issues untriaged New issue has not been triaged by the area owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants