question

TZacks-2728 avatar image
0 Votes"
TZacks-2728 asked samkatakouzinos commented

VS2022 and Nuget packages

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

dotnet-csharpdotnet-package-management
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

In Visual Studio 2022, menu 'Tools / NuGet Package Manager / Package Manager Settings', dialog 'Options / NuGet Package Manage / Package Sources', verify the NuGet source is listed.
Mine is 'nuget.org', 'https://api.nuget.org/v3/index.json'. Make sure it is enabled.
Had to add it manually on my computer's installation for NuGet Packages to start being successful.

198102-devenv-ark52mcwv1.png

0 Votes 0 ·
Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

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.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karenpayneoregon avatar image
0 Votes"
karenpayneoregon answered TZacks-2728 commented

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.

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

automatic download not happening in my case. so tell me where to issue this command dotnet restore ?

tell me which command prompt i should open to issue that command dotnet restore ?

am i missing any setting for which automatic download not happening in my case ?

thanks

0 Votes 0 ·

See Troubleshooting package restore errors (errors should appear in the output window if any). There is a link on this page to report an issue if nothing helps on the page.


0 Votes 0 ·

automatic download not happening in my case

Is it checked in Options like in the screenshot below ?


0 Votes 0 ·

My options looks same as per your screen shot. i am working with VS 2022 community Edition and i guess there is bug thank you

0 Votes 0 ·

Madam,

i i run this command dotnet restore from VS2022 IDE terminal prompt but still no luck. so later i download those missing nuget packages again from manage Nuget window from VS2022 IDE.

thanks

0 Votes 0 ·
Castorix31 avatar image
0 Votes"
Castorix31 answered

On my version, I have those options :

183394-nuget-options.jpg

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



nuget-options.jpg (109.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Sowmitri avatar image
0 Votes"
Sowmitri answered TZacks-2728 commented

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

i i run this command dotnet restore from VS2022 IDE terminal prompt but still no luck. so later i download those missing nuget packages again from manage Nuget window from VS2022 IDE.

thanks

0 Votes 0 ·