Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 6 Project builds successfully but won't build during any 'dotnet ef' command

I have an EF Core data layer project that is part of a bigger solution. It targets:

  • Output Type = Class Library
  • .NET 6.0 (Windows)
  • Target OS Version = 10.0.19041.0
  • Supported OS Version = 10.0.19041.0

It builds successfully in the normal way in Visual Studio, however when building as part of (for example) issuing a 'dotnet ef migrations list' command in the Package Manager console, it fails with:

An assembly specified in the application dependencies manifest (DataProvider2.deps.json) was not found:
package: 'runtimepack.Microsoft.Windows.SDK.NET.Ref', version: '10.0.19041.25'
path: 'Microsoft.Windows.SDK.NET.dll'

I have tried

  • Making the data project the startup project.
  • Removing the other projects so it's the only project in the solution.

What I don't understand is where it's getting '10.0.19041.25' from. I can't find it anywhere in any metadata files. I can't install the Nuget Package (dotnet add package Microsoft.Windows.SDK.NET.Ref --version 10.0.19041.25) as it targets the .NET Framework.

Where else could this reference be coming from?

like image 243
Alan B Avatar asked Oct 17 '25 17:10

Alan B


1 Answers

As always enlightenment comes after you post an SO question.

I created a new project and copied all the code into it and verified that it worked with EF Core commands. I then compared the .csproj files.

Apparently this is bad:

    <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>

but this is good:

<TargetFramework>net6.0</TargetFramework>

In case that helps anyone else.

like image 122
Alan B Avatar answered Oct 21 '25 19:10

Alan B



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!