dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
15.38k stars 4.75k forks source link

CreateAppHost fails processing Win32 resources #88465

Closed MichalStrehovsky closed 1 year ago

MichalStrehovsky commented 1 year ago

I have a simple res file created with rc.exe from this script:

LANGUAGE 0x041B, 0
funny RCDATA { 1L }
10 RCDATA { 3L }
LANGUAGE 0x0405, 0
funny RCDATA { 2L }
10 RCDATA { 4L }

You can download the res file here or just create it with rc.exe test.res (pasting the above test.res into a file): test.zip

If I add a reference to this res file into a blank console app:

<PropertyGroup>
  <Win32Resource>test.res</Win32Resource>
</PropertyGroup>

AppHost creation dies with this stack:

1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: The "CreateAppHost" task failed unexpectedly.
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: Microsoft.NET.HostModel.HResultException: 80070717
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.HostModel.ResourceUpdater.EnumResourcesErrorInfo.ThrowException()
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.HostModel.ResourceUpdater.AddResourcesFromPEImage(String peFile)
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.<>c__DisplayClass2_0.<CreateAppHost>g__UpdateResources|1()
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.HostModel.RetryUtil.RetryOnWin32Error(Action func)
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResourcesFrom, Boolean enableMacOSCodeSign)
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore()
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute()
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
ghost commented 1 year ago

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

Issue Details
I have a simple res file created with `rc.exe` from this script: ``` LANGUAGE 0x041B, 0 funny RCDATA { 1L } 10 RCDATA { 3L } LANGUAGE 0x0405, 0 funny RCDATA { 2L } 10 RCDATA { 4L } ``` You can download the res file here or just create it with `rc.exe test.res` (pasting the above test.res into a file): [test.zip](https://github.com/dotnet/runtime/files/11966535/test.zip) If I add a reference to this res file into a blank console app: ```xml test.res ``` AppHost creation dies with this stack: ``` 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: The "CreateAppHost" task failed unexpectedly. 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: Microsoft.NET.HostModel.HResultException: 80070717 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.HostModel.ResourceUpdater.EnumResourcesErrorInfo.ThrowException() 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.HostModel.ResourceUpdater.AddResourcesFromPEImage(String peFile) 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.HostWriter.<>c__DisplayClass2_0.g__UpdateResources|1() 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.HostModel.RetryUtil.RetryOnWin32Error(Action func) 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.HostModel.AppHost.HostWriter.CreateAppHost(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String assemblyToCopyResourcesFrom, Boolean enableMacOSCodeSign) 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore() 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 1>C:\Program Files\dotnet\sdk\8.0.100-preview.5.23303.2\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(643,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext() ```
Author: MichalStrehovsky
Assignees: -
Labels: `area-HostModel`
Milestone: -