skip to Main Content

I feel like something has broken in the latest version of mcr.microsoft.com/dotnet/sdk:6.0 as this was working just a few weeks ago, but I thought I’d post here to see if anyone has had similar problems and if there is a fix/workaround.

When trying to build, the following error is thrown

Step 9/18 : RUN dotnet publish "Test.Service.csproj" -c Release -o /app/publish
 ---> Running in f763996ec9e3
MSBuild version 17.3.0+92e077650 for .NET
  Determining projects to restore...
  Restored C:srcTest.ServiceTest.Service.csproj (in 15.18 sec).
  Restored C:srcTest.CoreTest.Core.csproj (in 15.18 sec).
  Restored C:srcTest.DataLayerTest.DataLayer.csproj (in 1.74 sec).
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018: The "GenerateResource" task failed unexpectedly. [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {7B8A2D94-0AC9-11D1-896C-00C04FB6BFC4} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)). [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at System.RuntimeTypeHandle.AllocateComObject(Void* pClassFactory) [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions) [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions) [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at System.Activator.CreateInstance(Type type) [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at Microsoft.Build.Tasks.GenerateResource.IsDangerous(String filename) [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at Microsoft.Build.Tasks.GenerateResource.Execute() [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [C:srcTest.DataLayerTest.DataLayer.csproj]
C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [C:srcTest.DataLayerTest.DataLayer.csproj]
The command 'cmd /S /C dotnet publish "Test.Service.csproj" -c Release -o /app/publish' returned a non-zero code: 1

Here is the DockerFile:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["NuGet.Config", "NuGet.Config"]
COPY ["Test.Service/Test.Service.csproj", "Test.Service/"]
COPY ["Test.DataLayer/Test.DataLayer.csproj", "Test.DataLayer/"]
COPY . .
WORKDIR "/src/Test.Service"

FROM build AS publish
RUN dotnet publish "Test.Service.csproj" -c Release -o /app/publish

FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS final
WORKDIR /app
EXPOSE 80
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Test.Service.dll"]

Building works when using the ubuntu-latest agent, but I can’t make it work using windows-latest. I’ve also tried windows-2019 with the same problem.

2

Answers


  1. Chosen as BEST ANSWER

    For now I'm using FROM mcr.microsoft.com/dotnet/sdk:6.0.200 AS build.

    I'm hoping a fix will be released at some point. It should be fixed along with this isue: https://github.com/dotnet/msbuild/issues/7946


  2. I have the same issue in my Azure pipeline build using a win2022. It just started within the last few weeks. I can build the container locally fine.

    Update: I tested removing the .resx file in my project and now it builds fine.

    C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018: The "GenerateResource" task failed unexpectedly.
    C:Program Filesdotnetsdk6.0.400Microsoft.Common.CurrentVersion.targets(3262,5): error MSB4018: System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {7B8A2D94-0AC9-11D1-896C-00C04FB6BFC4} failed due to the following error: 80040154 Class not registered (0x80040154 (REGDB_E_CLASSNOTREG)).
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search