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

"Invalid framework identifier" is lacking information #14044

Open
svew opened this issue Jan 16, 2025 · 3 comments
Open

"Invalid framework identifier" is lacking information #14044

svew opened this issue Jan 16, 2025 · 3 comments
Labels
Type:Bug WaitingForCustomer Applied when a NuGet triage person needs more info from the OP

Comments

@svew
Copy link

svew commented Jan 16, 2025

NuGet Product Used

MSBuild.exe

Product Version

MSBuild: 17.6.3.22601

Worked before?

No response

Impact

None

Repro Steps & Context

During MSBuild restore, I got the "Invalid framework identifier" error. This issue is not about the reasons for the error, but rather that the error is lacking information about what project caused it in the first place. I'm requesting that this error message also prints the path of the project its investigating when the error occurred.

I'm working in a repo with hundreds of C# projects, and I'm trying to set a default <TargetFramework> property across many of them. Obviously, at least one of these projects didn't receive the default value correctly, but which one?

Verbose Logs

NuGet.RestoreEx.targets(19,5): error : Invalid framework identifier ''. [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Frameworks.NuGetFramework.GetShortFolderName(IFrameworkNameProvider mappings) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.ProjectModel.PackageSpecWriter.WriteMetadataTargetFrameworks(IObjectWriter writer, ProjectRestoreMetadata msbuildMetadata) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.ProjectModel.PackageSpecWriter.SetMSBuildMetadata(IObjectWriter writer, PackageSpec packageSpec) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.ProjectModel.PackageSpecWriter.Write(PackageSpec packageSpec, IObjectWriter writer, Boolean hashing) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.ProjectModel.DependencyGraphSpec.Write(IObjectWriter writer, Boolean hashing, Action`3 writeAction) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.ProjectModel.DependencyGraphSpec.GetHash() [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreCommand.EvaluateCacheFile() [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreCommand.<ExecuteAsync>d__45.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreRunner.<ExecuteAsync>d__7.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreRunner.<ExecuteAndCommitAsync>d__6.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreRunner.<CompleteTaskAsync>d__9.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreRunner.<RunAsync>d__2.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Commands.RestoreRunner.<RunAsync>d__0.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Build.Tasks.BuildTasksUtility.<RestoreAsync>d__12.MoveNext() [...]
NuGet.RestoreEx.targets(19,5): error : --- End of stack trace from previous location where exception was thrown --- [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() [...]
NuGet.RestoreEx.targets(19,5): error :    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [...]
NuGet.RestoreEx.targets(19,5): error :    at NuGet.Build.Tasks.Console.MSBuildStaticGraphRestore.<RestoreAsync>d__14.MoveNext() [...]
@jebriede
Copy link
Contributor

@svew Thanks for reporting the issue. It would be good to improve the error messaging to help identify which project is having the issue. Can you please provide a minimal example solution that reproduces the Invalid framework identifier error so we can reproduce the issue and look into improving the messaging? Thanks!

@jebriede jebriede added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed Triage:Untriaged labels Jan 17, 2025
@svew
Copy link
Author

svew commented Jan 18, 2025

Steps to reproduce:

  1. Create a new .NET 5+ project of any variety
  2. Comment out/delete the <TargetFramework> property of the project file
  3. Run msbuild Project.csproj /t:Restore

@microsoft-github-policy-service microsoft-github-policy-service bot added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Jan 18, 2025
@jebriede
Copy link
Contributor

Removing the TargetFramework altogether results in a different error message (https://learn.microsoft.com/en-us/dotnet/core/tools/sdk-errors/netsdk1013):
error NETSDK1013: The TargetFramework value '' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.

That error seems to describe that scenario well and specifies the project where the issue occurs. What we would like to find is a repro for the Invalid framework identifier '' error you were seeing. Please let us know if you find a repro for that issue so we can pinpoint the issue.

@jebriede jebriede added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. labels Jan 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type:Bug WaitingForCustomer Applied when a NuGet triage person needs more info from the OP
Projects
None yet
Development

No branches or pull requests

2 participants