Unable to restore Packages when i change target framework from 4.5 to 4.8 using NugetPackage Manager

Rama Krishna boyina 21 Reputation points
2022-05-11T16:37:52.507+00:00

I changed target framework from 4.5 to 4.8.
When I am trying to build, packages are not restore correctly.

It seems my NugetPackage manager has problem.

201046-11st.png

201171-1st.png

201047-3rd.png

I added packages sources in nuget package manger in Tools-> options.
But it is not saving. I have installed nuget package manger and installed again.
But it is not working.
Could you please advise what to do with this.

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,337 questions
0 comments No comments
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 27,106 Reputation points Microsoft Vendor
    2022-05-13T03:44:26.857+00:00

    Hi @Rama Krishna boyina ,

    Welcome to Microsoft Q&A forum.

    Please navigate to %APPDATA%\NuGet( C:\Users\Admin\AppData\Roaming\NuGet ), then open NuGet.Config file, and check if the related package sources keys are added, for example:

      <packageSources>  
        <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />  
        <add key="Microsoft Visual Studio Offline Packages" value="C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\" />  
      </packageSources>  
    

    If there is no NuGet.Config file, please try to create a new NuGet.Config file. If there are no added package sources, please try to add several package sources that you want. You can refer to this doc: Nuget.config reference. After that restart VS and check Tools > NuGet Package Manager > Package Manager Settings > Package Sources.

    Besides, which version of Visual Studio are you using? Please also try to create a new solution and test if this issue appears on the newly created solution.

    Best Regards,
    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.

1 additional answer

Sort by: Most helpful
  1. Rama Krishna boyina 21 Reputation points
    2022-05-13T06:09:13.887+00:00

    Hi TianyuSun,

    Thank you for your response.
    I have verified my project. I am using visual studio 2017.
    I have nagivated to path (C:\Users\Admin\AppData\Roaming\NuGet) and found the file nuget.config.
    In this file I have only one entry.

    <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    </packageSources>

    I tried with new project. NuGet Package Manager > Package Manager Settings > Package Sources is populated. But my existing project it is populated.

    Please advise

    0 comments No comments