dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.7k stars 1.06k forks source link

The error message (& output) for NETSDK1148 could be MUCH more helpful #31557

Open mrlacey opened 1 year ago

mrlacey commented 1 year ago

A referenced assembly was compiled using a newer version of Microsoft.Windows.SDK.NET.dll. Please update to a newer .NET SDK in order to reference this assembly.

This error message is really vague. Which referenced assembly? What are the different versions that have been detected?

I ended up here after getting this message but being unable to determine which dependency had the issue. In fact, the only discrepancy in version numbers I could see was with the referenced assembly having a lower/older version of the SDK. I now don't know if the error message is wrong or if I'm looking at the wrong dependency.

I'm left in a situation where the error message is essentially saying "there's something wrong, I'm not going to tell you exactly what, but it's probably related to SDK versions." That's not very helpful!


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

tdykstra commented 1 year ago

The message implies that you just need to update the SDK that you're using to compile. Is it possible you don't have the latest version installed or you have a global.json file specifying an earlier version?

mrlacey commented 1 year ago

The message implies that you just need to update the SDK that you're using to compile. Is it possible you don't have the latest version installed or you have a global.json file specifying an earlier version?

"Just"?

As you point out, there are multiple places it could be looking for this, or it could be specified. If the error message told me which versions were being used by which projects/references (which it definitely knows as it's comparing them), that could greatly help in debugging this. By looking at the referenced version numbers in the projects, it's not clear where the problem is.

"Just" updating the SDK might not even do anything or risk breaking other compatibility issues. Plus, I already have the latest version installed, so that's not it.

I'm not looking for a solution to my specific issue (I found a workaround). I'm looking to make this easier for others who encounter this message in the future. (Or myself if I hit it again.)

tdykstra commented 1 year ago

@marcpopMSFT This is a request for details in the NETSDK1148 error message -- should I transfer the issue to the sdk repo or are there troubleshooting steps we can document that would help locate the cause of the error?

marcpopMSFT commented 1 year ago

Please transfer it to the SDK repo. The error lives in the SDK though is triggered by RAR returning ResolveAssemblyReferenceUnresolvedAssemblyConflicts so CC @Forgind for a comment.

baronfel commented 1 year ago

Here's the metadata we have access to at the point we send the error: https://github.com/dotnet/msbuild/blob/main/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs#LL1140-L1146

We should probably incorporate at least the logMessageDetails into the SDK-delivered warning, because that metadata seems to capture the references that caused the conflict. What we can't easily do is point to which SDK a user should update to given the known Windows SDK version - we don't have any sort of mapping from the constituent part of a published SDK to the overall SDK number.

Forgind commented 1 year ago

Here's the metadata we have access to at the point we send the error: https://github.com/dotnet/msbuild/blob/main/src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs#LL1140-L1146

This is spot on.

we don't have any sort of mapping from the constituent part of a published SDK to the overall SDK number.

Though this is true, I imagine it wouldn't be too hard to figure out manually for most users. If you have, say, three Windows SDKs on your machine, and you know the desired version of a particular constituent part, you can just look at the version for each of those three SDKs and see which matches. I agree it would be nice if we could be more clear there, but RAR has no idea where the references came from.