How do I include NuGet packages in my solution for .Net Core projects?

ⅰ亾dé卋堺 提交于 2019-11-29 14:45:01

A lot of NuGet behaviour can be controlled via NuGet.Config files (See this reference for more details)

If you place a NuGet.Config file next to the solution with the following content, you can override the location that the packages will be restored into:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="globalPackagesFolder" value=".\packages" />
  </config>
</configuration>

If the problem is that you'd need to set up additional sources in VS on every machine, you can also add those sources via a NuGet.Config in your repository so VS will pick up the feeds to use when opening a solution:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="CompanyFeed" value="https://my.company.com/private/nuget" />
  </packageSources>
</configuration>

If you have no feed to host packages and need to include packages with the solution, you can use a directory containing .nupkg files as well in NuGet.Config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="local" value=".\NuGetPackages" />
  </packageSources>
</configuration>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!