How to use NuGet packages with an ASP.NET Website on CI Server

荒凉一梦 提交于 2019-12-01 04:42:42

After some time, I have a workaround that gets me where I need to be, albeit not in the best way.

In newer versions of Visual Studio, when a binary dependency is added to a website via VS, it adds a (binaryfile).dll.refresh file to the bin folder alongside the binary file. The contents of the file is the relative path to the .dll via the packages folder for the solution. In addition, a packages.config file is added to the website.

The way to get it to build on a CI server is:

  1. Ignore (.gitignore, .hgignore) the website's bin folder
  2. Explicitly add the .refresh file(s) in the bin folder
  3. Prior to the actual build, call NuGet restore, passing in the path to the website's packages.config and setting the PackagesDirectory (or SolutionDirectory) to the packages folder for the solution
  4. Pre-Compile, MSBuild will open each refresh file, and copy the file from the location contained in the file.

It's not a great solution, because I now have to call NuGet restore multiple times (once for solution, once for each website), but it does work. I don't know how far back the .refresh file is supported, but it does work in 2015. I may make a change request in NuGet to allow for multiple solutions/packages.configs to be passed in via the command line.

Thanks, Erick

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!