re-run NuGet restore issue

iqworks Information Quality Works 216 Reputation points
2024-04-19T19:01:12.5166667+00:00

 

Hi, I already have my target framework set to 4.7.2. So I tried to do a Nuget restore :

User's image

I tried to do a nuget restore and got this error.User's image

I am not sure what I should do or try now?

thanks for any advice or suggestions

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
4,618 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,356 Reputation points Microsoft Vendor
    2024-04-22T06:38:32.75+00:00

    Hello @iqworks Information Quality Works ,

    Sometimes, the project cache may cause this issue(something in one of the cache files maybe still reference to an old version of .NET Framework).

    Please try to remove bin, obj and the hidden .vs folder manually, and then rebuild your project, do a NuGet restore.

    Sincerely,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Michael Taylor 48,486 Reputation points
    2024-04-22T21:26:15.9733333+00:00

    What type of project is this? Go to the file system where the project resides, is it a .csproj file?

    Open the file in a text editor. Is it XML and does it start with something like

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    

    If it doesn't then the project file isn't correct. If it does then find the <TargetFrameworks> element. It should have a value of v4.7.2.

    If the file instead looks like this.

    <Project Sdk="Microsoft.NET.Sdk.Web">
      <PropertyGroup>
    

    Then you're using a new SDK-format project for .NET framework. This isn't going to work out well so create a new ASP.NET project targeting NET Framework. If this is not a web-project then you can use the SDK format but ensure you have the following element inside a PropertyGroup.

    <TargetFramework>net472</TargetFramework>
    

    I'm assuming here you're actually loading the solution/web project. If you aren't then nothing is going to work.