Visual Studio giving errors about incompatible packages that are not installed

Yossu 11 Reputation points
2022-11-20T14:52:38.523+00:00

I have an ASP.NET Blazor server-side solution that I (and other team members) have been working on for months.

I just pulled the code from source control onto my lap top. However, VS gives errors like this...

Package Microsoft.Win32.Registry 5.0.0 is not compatible with net7.0 (.NETCoreApp,Version=v7.0). Package Microsoft.Win32.Registry 5.0.0 does not support any target frameworks.

I get these errors for every project in the solution, along with similar errors for System.Security.Principal.Windows and Humanizer.Core.

However, as far as I can see, none of these packages are referenced anywhere in the solution. I haven't referenced them, and looking through all the dependencies I have, I can't see any of these three as dependencies of referenced packages.

The only differences I can see between my dev machine and my lap top are that the dev machine is on Win7 with VS2022 17.4.0, whereas the lap top is Win11 with VS2022 17.4.1.

During one cycle of pulling a fresh copy of the code from DevOps, restarting both VS and the lap top etc, VS gave me a message when I loaded the solution, saying that in order to get the best experience (whatever that means), I needed to add some missing workflow types. VS Installer popped up and asked me to install the .NET Desktop workflow. No idea why, as this solution only has ASP.NET and MAUI projects, but given that the errors included Microsoft.Win32.Registry, I thought I'd give it a go. Sadly it didn't help.

I tried changing the TargetFramework to <TargetFramework>net7.0-windows</TargetFramework>, but it didn't make any difference.

In case it helps, here is the full .csproj file for one of the projects. I get all three errors in this project...

<Project Sdk="Microsoft.NET.Sdk">  
  
  <PropertyGroup>  
    <TargetFramework>net7.0</TargetFramework>  
    <ImplicitUsings>enable</ImplicitUsings>  
    <Nullable>enable</Nullable>  
  </PropertyGroup>  
  
  <ItemGroup>  
    <PackageReference Include="LanguageExt.Core" Version="4.2.9" />  
    <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />  
    <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="7.0.0" />  
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="7.0.0" />  
    <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="7.0.0" />  
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />  
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.0">  
      <PrivateAssets>all</PrivateAssets>  
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>  
    </PackageReference>  
    <PackageReference Include="Pixata.Extensions" Version="1.23.0" />  
  </ItemGroup>  
  
  <ItemGroup>  
    <ProjectReference Include="..\MyProject.CommonHelpers\OneGiv.CommonHelpers.csproj" />  
  </ItemGroup>  
  
</Project>  

Anyone any ideas?

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,873 questions
Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,146 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Furkan Cengiz 0 Reputation points
    2023-02-28T10:14:59.8466667+00:00

    I guess I have the similar issue. I've been using .net 7 since its release and the projects were working fine but even if I tried reinstalling sdks, runtime and visual studio, it still throws these errors. I downloaded the project to my laptop and it worked fine. I can't figure out what happened and what to do. Please help...

    User's image

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.