VS2022 and Nuget packages

T.Zacks 3,986 Reputation points
2022-03-15T17:07:42.61+00:00

I have created a winform project using .net core and i have add a library from nuget from nuget package manager UI from VS2022. my program compile perfectly but when i shared my project with my colleague and when my colleague open that open then that libabry was missing at his end which i add to my project by nuget.

so my colleagues has to add again that library to project from nuget. the problem is when i add a package to project from nuget then why my colleague has to add again from VS2022 IDE?

do i need to turn on any option in VS2022 IDE as a result package will be downloaded when anyone open or compile the project ?

what i can do at my end as a result those packages should be downloaded at colleagues pc if found missing automatically ?

i found no package.json file in my winform .net core project. when this file is created ? why it is missing? is this file only created for asp.net core project type?

please guide me. thanks

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,395 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,276 questions
{count} votes

4 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,686 Reputation points
    2022-03-15T17:22:06.473+00:00

    nuget references have been moved to the project file. if you open the project file you should see the nuget package reference. sample for Newtonsoft:

      <ItemGroup>
        <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
      </ItemGroup>
    

    maybe you failed to save the changed project file.

    0 comments No comments

  2. Karen Payne MVP 35,036 Reputation points
    2022-03-15T18:58:48.717+00:00

    what i can do at my end as a result those packages should be downloaded at colleagues pc if found missing automatically ?

    They should auto download when Visual Studio opens the project, if not open a command prompt and issue dotnet restore. Note that NuGet stores packages in a cache so the next time a package is needed it get it from the cache.


  3. Castorix31 81,741 Reputation points
    2022-03-15T19:04:53.09+00:00

    On my version, I have those options :

    183394-nuget-options.jpg

    And when I open a project with old packages, they are automatically updated

    0 comments No comments

  4. Sowmitri 26 Reputation points
    2022-03-16T08:49:11.057+00:00

    Hi,
    I recently worked on VS 2019. nuget packages are built-in to be accessed through Visual Studio (Community edition). Apart from that this version onwards, Visual Studio installer takes care of installation related issues (if any). project dependencies sometimes get dropped from machine. in that case repair or clean and reload project helps to compile as earlier. hope it helps. also I have not practically worked on VS2022 yet. but most behaviour might be same as VS 2019. let me know of any queries or concerns still being faced.