Skip to content

On dotnet publish for Mac, getting unclear error "error MSB4018: The "GenerateDepsFile" task failed unexpectedly... System.InvalidOperationException: Unrecognized AssetType 'resource' " #40015

@idigra

Description

@idigra

Describe the bug

When trying to dotnet publish a project with dependencies, I'm getting the MSBuild exception below.
Based on looking at dotnet code, I guess that the error is probably due to some typo in the package creation, where instead of resources, the word resource was used (I understood it by the code around the exception thrown here:
https://github.com/dotnet/sdk/blob/a1fdd359f85eaa8a7ebb68b4856b0dc559543a93/src/Tasks/Microsoft.NET.Build.Tasks/ResolvedFile.cs#L75C17-L76C1)

However I can't I understand from the exception and the code around where should I look for that typo in our code or even in the binary or package metadata.

Short term - please advice what exactly should I look at.
Long term - consider providing clearer error message.

To Reproduce

Dependency tree is complex and due to the unclear error message I don't know how to minimize the code into simple repro, sorry.
On private call I'll be able to provide the faulty package and to share the environment where I reproduced the bug.

Exceptions (if any)

(Obfuscated some private paths from the logs below)

/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018: The "GenerateDepsFile" task failed unexpectedly. [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018: System.InvalidOperationException: Unrecognized AssetType 'resource' for /Volumes/.../%NugetMachineInstallRoot%/.pkgref/PackageName/2.127.7249-prerelease-007/runtimes/osx/lib/net6.0/ar/BinaryName.resources.dll [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.NET.Build.Tasks.ResolvedFile..ctor(ITaskItem item, Boolean isRuntimeTarget) [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.<>c.<WriteDepsFile>b__120_3(ITaskItem f) [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at System.Linq.Enumerable.SelectArrayIterator`2.MoveNext() [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at System.Linq.Enumerable.ConcatIterator`1.MoveNext() [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at System.Linq.Lookup`2.Create(IEnumerable`1 source, Func`2 keySelector, IEqualityComparer`1 comparer) [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at System.Linq.GroupedEnumerable`2.GetEnumerator() [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.NET.Build.Tasks.DependencyContextBuilder.WithResolvedNuGetFiles(IEnumerable`1 resolvedNuGetFiles) [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.NET.Build.Tasks.GenerateDepsFile.WriteDepsFile(String depsFilePath) [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.NET.Build.Tasks.TaskBase.Execute() [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [MyProject.csproj::TargetFramework=net8.0]
/usr/local/share/dotnet/sdk/8.0.202/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.targets(284,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost taskExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemBucket bucket, TaskExecutionMode howToExecuteTask) [MyProject.csproj::TargetFramework=net8.0]

Further technical details

- Include the output of `dotnet --info`
.NET SDK:
 Version:           8.0.202
 Commit:            25674bb2f4
 Workload version:  8.0.200-manifests.4e94be9c

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  14.4
 OS Platform: Darwin
 RID:         osx-arm64
 Base Path:   /usr/local/share/dotnet/sdk/8.0.202/

.NET workloads installed:
There are no installed workloads to display.

Host:
  Version:      8.0.3
  Architecture: arm64
  Commit:       9f4b1f5d66

.NET SDKs installed:
  6.0.420 [/usr/local/share/dotnet/sdk]
  7.0.407 [/usr/local/share/dotnet/sdk]
  8.0.202 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.28 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.17 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.28 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 8.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  x64   [/usr/local/share/dotnet/x64]
    registered at [/etc/dotnet/install_location_x64]

Environment variables:
  Not set

global.json file:
  /Volumes/.../global.json

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    No IDE, running the following line from command line:
    dotnet publish --interactive -c Debug-Mac -f net8.0 <project-path>

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions