Using SDK version 3.0.100-preview-009734
microsoft/nanoserver container with dotnet 3.0 SDK installed (e.g. microsoft/dotnet-nightly:3.0-sdk Dockerfile)Results:
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.RuntimeIdentifierInference.targets(142,5): message NETSDK1057: You are using a preview version of .NET Core. See: https://aka.ms/dotnet-core-preview [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: The "CreateAppHost" task failed unexpectedly. [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: System.EntryPointNotFoundException: Unable to find an entry point named 'BeginUpdateResource' in DLL 'Kernel32'. [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResourceUpdater.Kernel32.BeginUpdateResource(String pFileName, Boolean bDeleteExistingResources) [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: at Microsoft.NET.Build.Tasks.AppHost.Create(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean windowsGraphicalUserInterface, String intermediateAssembly, Logger log) in /_/src/Tasks/Microsoft.NET.Build.Tasks/AppHost.cs:line 82 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore() in /_/src/Tasks/Microsoft.NET.Build.Tasks/CreateAppHost.cs:line 38 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() in /_/src/Tasks/Common/TaskBase.cs:line 35 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009734\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(293,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\app\app.csproj]
Build FAILED.
@peterhuene - Is this something you know about?
cc. @nguerrera @sbomer.
Looks like we'll either need an OS check or check that theBeginUpdateResource export exists ourselves.
Is there an ETA on when this is going to get fixed? It is a significant regression in the Windows container space.
I'm hoping to have the fix in this week (ideally tomorrow). This is my priority issue atm.
Is there a workaround? Like setting UseApphost to false? Just in case this does not make into the preview1 build?
Setting UseAppHost to false either in the project file or passing as a global property to dotnet build should workaround the issue.
I am leaning towards not taking this in Preview 1. Is there an ENV we can set for UseAppHost instead of putting in a project file?
Setting it as an environment variable should also work.
Will it break self-contained-deployment if set as environment variable?
Good point. It will error and users would have to override via setting the property.
Still a less severe thing to document for the container than every build failing...
So after testing this out on the various different nano-server versions, this requires two fixes:
BeginUpdateResource is apparently exported by Kernel32.dll, but returns a null update handle and sets a zero (or >0xffff?) error code, resulting in a HResultException (HRESULT 0x80070000) from ResourceUpdater..ctor. Thus, we need to expect this error condition and treat as if the export doesn't exist.BeginUpdateResource isn't exported (resulting in the exception from this issue), so we need to check for its existence.My fix only worked for the second one, so I'm fixing now to address both.
I'm not sure the second fix is needed. I've been told Nano Server sac2016 is EOL as of Nov 1st.
I don't see either BeginUpdateResourceA or BeginUpdateResourceW being exported from kernel32.dll in 1709+ too, so I'm perplexed why we got past the missing export and into a place that should only throw if the p/invoke call occurred.
@MichaelSimons are you seeing the same behavior (HResultException with 8007000) with a 1709+ image (i.e. tags 3.0.100-preview-sdk-nanoserver-1709, 3.0.100-preview-sdk-nanoserver-1803, or 3.0.100-preview-sdk-nanoserver-1809/3.0-sdk)?
I'm putting up a fix that should work for all of the above, although I still haven't determined why the BeginUpdateResource export resolves.
@MichaelSimons Michael Simons (.NET) FTE are you seeing the same behavior (HResultException with 8007000) with a 1709+ image (i.e. tags 3.0.100-preview-sdk-nanoserver-1709, 3.0.100-preview-sdk-nanoserver-1803, or 3.0.100-preview-sdk-nanoserver-1809/3.0-sdk)?
This is what I am seeing on 1709+
Microsoft.NET.Build.Tasks.ResourceUpdater+HResultException: 80070000
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: The "CreateAppHost" task failed unexpectedly. [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: Microsoft.NET.Build.Tasks.ResourceUpdater+HResultException: 80070000 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: at Microsoft.NET.Build.Tasks.ResourceUpdater.ThrowExceptionForLastWin32Error() in /_/src/Tasks/Microsoft.NET.Build.Tasks/ResourceUpdater.cs:line
404 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: at Microsoft.NET.Build.Tasks.AppHost.Create(String appHostSourceFilePath, String appHostDestinationFilePath, String appBinaryFilePath, Boolean w
indowsGraphicalUserInterface, String intermediateAssembly, Logger log) in /_/src/Tasks/Microsoft.NET.Build.Tasks/AppHost.cs:line 40 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: at Microsoft.NET.Build.Tasks.CreateAppHost.ExecuteCore() in /_/src/Tasks/Microsoft.NET.Build.Tasks/CreateAppHost.cs:line 38 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: at Microsoft.NET.Build.Tasks.TaskBase.Execute() in /_/src/Tasks/Common/TaskBase.cs:line 35 [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:\app\app.csproj]
C:\Program Files\dotnet\sdk\3.0.100-preview-009784\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.targets(294,5): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, Task
Host taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:\app\app.csproj]
0 Warning(s)
1 Error(s)