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

InvalidOperationException from TaskLoggingHelper.FormatResourceString(): The "Csc" task has not registered its resources. #6253

Closed
KirillOsenkov opened this issue Mar 15, 2021 · 29 comments
Labels
Area: Tasks Issues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll. bug needs-design Requires discussion with the dev team before attempting a fix. triaged
Milestone

Comments

@KirillOsenkov
Copy link
Member

Building using bootstrap MSBuild from 80b7f2d has resulted in a Csc failure:

Csc
    Assembly = C:\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\Roslyn\Microsoft.Build.Tasks.CodeAnalysis.dll
C:\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\Roslyn
    Microsoft (R) Visual C# Compiler version 3.9.0-2.20574.26 (e9fd4dc7)
    Errors
        C:\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018: The "Csc" task failed unexpectedly.
This is an unhandled exception from a task -- PLEASE OPEN A BUG AGAINST THE TASK OWNER.
System.InvalidOperationException: The "Csc" task has not registered its resources. In order to use the "TaskLoggingHelper.FormatResourceString()" method this task needs to register its resources either during construction, or via the "TaskResources" property.
   at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args) in C:\msbuild\src\Shared\ErrorUtilities.cs:line 327
   at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInvalidOperation(Boolean condition, String resourceName, Object arg0) in C:\msbuild\src\Shared\ErrorUtilities.cs:line 368
   at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args) in C:\msbuild\src\Shared\TaskLoggingHelper.cs:line 203
   at Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorWithCodeFromResources(String subcategoryResourceName, String file, Int32 lineNumber, Int32 columnNumber, Int32 endLineNumber, Int32 endColumnNumber, String messageResourceName, Object[] messageArgs) in C:\msbuild\src\Shared\TaskLoggingHelper.cs:line 825
   at Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorWithCodeFromResources(String messageResourceName, Object[] messageArgs) in C:\msbuild\src\Shared\TaskLoggingHelper.cs:line 779
   at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)
   at Microsoft.Build.Utilities.ToolTask.Execute() in C:\msbuild\src\Utilities\ToolTask.cs:line 1519
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() in C:\msbuild\src\Build\BackEnd\TaskExecutionHost\TaskExecutionHost.cs:line 578
   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() in C:\msbuild\src\Build\BackEnd\Components\RequestBuilder\TaskBuilder.cs:line 809 [C:\Ide\src\CodexShell\CodexShell.csproj]
@KirillOsenkov KirillOsenkov added bug needs-triage Have yet to determine what bucket this goes in. labels Mar 15, 2021
@KirillOsenkov
Copy link
Member Author

This was intermittent and happened only once.

dotnet/roslyn#46772 is potentially related or same issue.

@KirillOsenkov KirillOsenkov added the Area: Tasks Issues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll. label Mar 15, 2021
@cecilphillip
Copy link

I'm running into this issues on MacOs Big Sur when using Project Tye to run a Blazor project. The other projects in the solution (one webapi and one console) build fine. This also only started happening when I upgraded my project to .NET 5

@conniey
Copy link
Member

conniey commented Apr 3, 2021

Same on big sur with a .NET Core console application. :(

@Edo90
Copy link

Edo90 commented Apr 7, 2021

I'm having the same issues, on Windows 10, and still no solution so far.

The "Csc" task failed unexpectedly.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018: System.InvalidOperationException: The "Csc" task has not registered its resources. In order to use the "TaskLoggingHelper.FormatResourceString()" method this task needs to register its resources either during construction, or via the "TaskResources" property.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInvalidOperation(Boolean condition, String resourceName, Object arg0)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorWithCodeFromResources(String messageResourceName, Object[] messageArgs)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands)
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.ToolTask.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Roslyn\Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()

@benvillalobos
Copy link
Member

Team Triage: @KirillOsenkov We're wondering how/where this would be an issue with MSBuild. At first glance this looks like an issue with Roslyn as it's in a targets file under Roslyn\ and has to do with the csc task.

@KirillOsenkov
Copy link
Member Author

@jaredpar we think there's an intermittent issue with the Csc task, any quick guesses? Have you seen this before?

@KirillOsenkov
Copy link
Member Author

As far as I can tell, this is where Csc initializes its resources, which is pretty early on, in the constructor of the base class: https://github.com/dotnet/roslyn/blob/275f4c790945c73ca308716ba56c224a95e13ca9/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs#L59

Should it be calling this constructor instead?

protected ToolTask(ResourceManager taskResources)

@jaredpar
Copy link
Member

jaredpar commented Apr 7, 2021

Never seen this before nor do I know what is required. Just based off the info here I suspect we're running into the following line

https://github.com/dotnet/roslyn/blob/main/src/Compilers/Core/MSBuildTask/ManagedCompiler.cs#L557

At the same time I'm not sure what is missing that we should be doing.

@KirillOsenkov
Copy link
Member Author

Yup, you're right, it looks like there's an exception on that line (we don't know which one), and when trying to log it, we fail to get the resource string because resources haven't been initialized.

@jeffkl
Copy link
Contributor

jeffkl commented Apr 7, 2021

Yeah you need to register resources via the constructor or the TaskResources property

/// Gets or sets the task's culture-specific resources. Derived classes should register their resources either during

@KirillOsenkov
Copy link
Member Author

I've filed Roslyn issue dotnet/roslyn#52467 - would be nice to fix this soon, as a lot of customers are hitting this

@jaredpar
Copy link
Member

jaredpar commented Apr 20, 2021

Yeah you need to register resources via the constructor or the TaskResources property

Turn out this isn't 100% true. The problem is that we're going through TaskLoggingHelper. Even though that takes an ITask as a constructor argument it does not utilize the ITask.TaskResources property. Instead you have to manually set that up on TaskLoggingHelper instances.

So even though our Task registered everything properly the TaskLoggingHelper didn't take advantage of it. That's a bit unintuitive.

@KirillOsenkov
Copy link
Member Author

Yeah I think I saw you're creating an isolated TaskLoggingHelper that's disconnected from the task, and one probably needs to pass stuff to it for it to work as expected. Unfortunately this silly exception is hiding the real exception that's happening in the compiler server.

@jaredpar
Copy link
Member

Yep. Thats' what I get for trying to use the right API for logging exceptions 😦

Fix is easy but testing requires me to restructure the code a bit.

@benvillalobos
Copy link
Member

Team Triage: Closing since the fix is available within roslyn. @jaredpar if you think there's anything we can do in our API to make this easier, let us know.

@jaredpar
Copy link
Member

Team Triage: Closing since the fix is available within roslyn. @jaredpar if you think there's anything we can do in our API to make this easier, let us know.

IMHO, you should really consider one of two bug fixes here:

  1. Change TaskLoggingHelper to initialize TaskResources based on the ITask in the constructor
  2. Change TaskLoggingHelper.TaskResources to fall back to ITask.TaskResources if the value is null

This seems relatively safe because in the cases where this has an impact the code would already be in a failure state. I imagine I'm not the only one who making the assumption that a type named TaskLoggingHelper would attempt to get critical state from the provided ITask.

@jaredpar jaredpar reopened this Apr 21, 2021
@jaredpar
Copy link
Member

Sorry, accidentally button slip and hit re-open.

@benvillalobos
Copy link
Member

Change TaskLoggingHelper.TaskResources to fall back to ITask.TaskResources if the value is null

Sounds to me like a reasonable ask, Reopening for triage

@jaredpar
Copy link
Member

BLARG you also need to manually set IBuildEngine in the TaskLoggingHelper.

At this point I think the fastest way to fix this bug is to stop using TaskLoggingHelper. It's just causing pain at this point because the usability level is not good. Really think you all should add constructors that actually take the arguments necessary to make type functional and deprecate the existing ones. Current state is just leading users to this type of bug.

@benvillalobos benvillalobos added needs-design Requires discussion with the dev team before attempting a fix. and removed needs-triage Have yet to determine what bucket this goes in. labels May 12, 2021
@danmoseley
Copy link
Member

@benvillalobos in dotnet/runtime we've gotten random build failures with this callstack. +1 to some fix this iteration.

@jaredpar
Copy link
Member

This was fixed in dotnet/roslyn#52836. Newer versions of the SDK should have the fix and give the correct stack traces.

@dglozano
Copy link

Hi @jaredpar I was wondering what is it that I need to update in order to get the fix? I am a little lost.
I have upgraded my SDK to the latest version (released June 8 2021, v 5.0.301 ) but I still see this error when trying to build my NET 5 WebApi project in my Mac Big Sur

@jaredpar
Copy link
Member

jaredpar commented Jun 10, 2021

@dglozano

My expectation is that this would be included in 5.0.301 as that change went into VS 16.10. Can you grab a bin log of the build there and share that out? Want to make sure it's using the expected compiler vs. getting one pushed in via a package.

Note: since this bug was closed we did see the failures start to popup in our repos. This is the most likely candidate at the moment dotnet/runtime#53420

@dglozano
Copy link

dglozano commented Jun 13, 2021

Hi @jaredpar here is what I could get. I have never generated a binlog before. I was expecting a file to be generated, but I can't find one in the path I specified... so I am just attaching the console output.

Not sure if it's this what you need. Let me know if there is anything else I could get for you.

dotnet build -bl:~/Logs/msbuild.binlog                                                                                                       1 ↵ dglozano@DGLOZANO
Microsoft (R) Build Engine version 16.10.1+2fd48ab73 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

/usr/local/share/dotnet/sdk/5.0.301/MSBuild.dll -bl:~/Logs/msbuild.binlog -consoleloggerparameters:Summary -distributedlogger:Microsoft.DotNet.Tools.MSBuild.MSBuildLogger,/usr/local/share/dotnet/sdk/5.0.301/dotnet.dll*Microsoft.DotNet.Tools.MSBuild.MSBuildForwardingLogger,/usr/local/share/dotnet/sdk/5.0.301/dotnet.dll -maxcpucount -restore -verbosity:m ./Altus.DI.UI.Web.Net5.csproj
  Determining projects to restore...
  All projects are up-to-date for restore.
  Altus.DI.Core -> /Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.Core/bin/Debug/netstandard2.0/Altus.DI.Core.dll
  Altus.DI.Shared -> /Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.Shared/bin/Debug/netstandard2.0/Altus.DI.Shared.dll
  Altus.DI.Repository -> /Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.Repository/bin/Debug/netstandard2.0/Altus.DI.Repository.dll
  Altus.DI.Proxy -> /Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.Proxy/bin/Debug/netstandard2.0/Altus.DI.Proxy.dll
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018: The "Csc" task failed unexpectedly. [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018: System.InvalidOperationException: The "Csc" task has not registered its resources. In order to use the "TaskLoggingHelper.FormatResourceString()" method this task needs to register its resources either during construction, or via the "TaskResources" property. [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInvalidOperation(Boolean condition, String resourceName, Object arg0) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorWithCodeFromResources(String messageResourceName, Object[] messageArgs) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.ToolTask.Execute() [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]

Build FAILED.

/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018: The "Csc" task failed unexpectedly. [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018: System.InvalidOperationException: The "Csc" task has not registered its resources. In order to use the "TaskLoggingHelper.FormatResourceString()" method this task needs to register its resources either during construction, or via the "TaskResources" property. [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInvalidOperation(Boolean condition, String resourceName, Object arg0) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.FormatResourceString(String resourceName, Object[] args) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.TaskLoggingHelper.LogErrorWithCodeFromResources(String messageResourceName, Object[] messageArgs) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.CodeAnalysis.BuildTasks.ManagedCompiler.ExecuteTool(String pathToTool, String responseFileCommands, String commandLineCommands) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.Utilities.ToolTask.Execute() [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
/Users/dglozano/.nuget/packages/microsoft.net.compilers/3.9.0/tools/Microsoft.CSharp.Core.targets(71,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [/Users/dglozano/Projects/digital-well-intervention/src/Altus.DI.UI.Web.Net5/Altus.DI.UI.Web.Net5.csproj]
    0 Warning(s)
    1 Error(s)

Time Elapsed 00:00:02.32

And the output of dotnet --info just in case.

.NET SDK (reflecting any global.json):
 Version:   5.0.301
 Commit:    ef17233f86

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  11.0
 OS Platform: Darwin
 RID:         osx.11.0-x64
 Base Path:   /usr/local/share/dotnet/sdk/5.0.301/

Host (useful for support):
  Version: 5.0.7
  Commit:  556582d964

.NET SDKs installed:
  3.1.302 [/usr/local/share/dotnet/sdk]
  3.1.409 [/usr/local/share/dotnet/sdk]
  5.0.203 [/usr/local/share/dotnet/sdk]
  5.0.300 [/usr/local/share/dotnet/sdk]
  5.0.301 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.15 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.20 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.15 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.6 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

@jaredpar
Copy link
Member

@dglozano thanks that confirmed my suspicions

image

Your project / solution has an installation of Microsoft.Net.Compilers that is overriding the C# compiler that comes from the SDK. Removing that will let you use the C# compiler that comes with the SDK that should have this fix.

Note: in general that package is not supported for long term usage of this sort. It is meant as a mechanism for shipping short term patches to customers only.

@dglozano
Copy link

Thanks @jaredpar ! Can confirm that removing the nuget package fixed the issue 🎊

jaredpar added a commit to dotnet/roslyn that referenced this issue Aug 26, 2021
Similar to other tasks we fixed previously we need to ensure that
resources are set correctly when creating the `CopyRefAssembly` task.
The only correct way to do this is pass the `ResourceManager` through
the constructor.

Follow up of #52836
Related to dotnet/msbuild#6253
@cihancoskun
Copy link

I got the same problem. And it is very interesting that when I run Visual Studio as administrator, I was able to get build without any problem.

@danmoseley
Copy link
Member

@cihancoskun at this point it's better to open a new issue with any other info. I would also try repairing your installs since maybe a file has the wrong ACL? (not sure whether repair fixes ACLS)

@tavisca-devendra
Copy link

I have got the same issue and tried to rebuild and my Jenkins jobs completed successfully, looks like this is an intermittent issue

@AR-May AR-May added the triaged label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Tasks Issues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll. bug needs-design Requires discussion with the dev team before attempting a fix. triaged
Projects
None yet
Development

No branches or pull requests