2

In Visual Studio how can I avoid having to download a package like entity framework each time I create a new project?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Hassan Fayyaz
  • 685
  • 1
  • 9
  • 15
  • You cannot, unless all projects are using package references. When package references are used, NuGet packages are downloaded only once and saved to a cache for your logon account. – Lex Li Mar 28 '18 at 21:41

1 Answers1

0

One solution that might work for you is to create a project exactly as you want it and keep it as a template, or you could also copy that project to start a new project instead of starting from scratch. See this SO post Visual Studio Copy Project. The marked answer speaks to copying, but one of the other posts speaks about templates and might give you a starting point.

It would be nice if you could run a script inside the package manager, but I have never found a source that directly explains how to do that. Perhaps another user could add that to this thread if they know how to do that.

Alan
  • 1,587
  • 3
  • 23
  • 43
  • You can test that out yourself. I don't think it would work if `packages.config` is used. – Lex Li Mar 28 '18 at 21:42
  • @LexLi just to clarify for me, which part in my answer are you referring to for testing? – Alan Mar 28 '18 at 21:45
  • If your project template uses `packages.config`, then every time creating a project from it would lead to the downloads of NuGet packages, as NuGet cache is per solution in that case. Thus, your answer is not 100% correct. – Lex Li Mar 28 '18 at 21:47
  • @LexLi Got it. Thx. But the template or copy process, my primary suggestion, should work for the ops request, yes? – Alan Mar 28 '18 at 21:49
  • Probably, but I don't think using a custom template is **a must**. As long as package reference is used, NuGet cache is per logon account, which can significantly reduce the downloads from NuGet.org. – Lex Li Mar 28 '18 at 21:50