问题描述
如果您有一个 ASP.NET 网站项目类型(没有正确的 .csproj 或 .vpproj 项目文件,并且只是一个松散文件的文件夹),那么当您使用 NuGet 添加一个包时,它会生成一个Bin 目录下的 *.dll.refresh 文件,用于引用父包文件夹中包的 dll.
If you have an ASP.NET Web Site project type (the one without a proper .csproj or .vpproj project file and that is just a folder of loose files), then when you add a package with NuGet, it makes a *.dll.refresh file in the Bin directory to reference the package's dll in the parent packages folder.
例如,如果你从 Package Manager Console 执行install-package elmah",那么 Elmah 会被放置在项目的解决方案目录下的 packages 文件夹中,而文件 Elmah.dll.refresh 会被放置在项目的 Bin 文件夹中.
For example, if you execute "install-package elmah" from the Package Manager Console, then Elmah is placed in the packages folder in the project's solution directory, and the file Elmah.dll.refresh is placed in the project's Bin folder.
当我在本地构建项目时,Visual Studio 会自动拉入刷新文件引用的 DLL.该站点和 Elmah 运行正常.我没有将位于项目 Bin 目录中的 Elmah.dll 文件签入源代码管理(仅签入刷新文件和包文件夹).
When I build the project locally, Visual Studio automatically pulls in the DLL referenced by the refresh file. The site and Elmah run correctly. I don't have the Elmah.dll file that sits in the project's Bin directory checked in to source control (only the refresh file and the packages folder are checked in).
但是,我正在使用 Web 部署项目来预编译站点并为部署执行 web.config 替换.以这种方式构建解决方案时,不会自动将 Elmah.dll 拉入网站项目 Bin 目录,并且由于缺少 DLL,该网站无法正常运行.
However, I'm using Web Deployment Projects to pre-compile the site and do web.config substitutions for deployments. When the solution is built this way, Elmah.dll is not automatically pulled in to the web site project Bin directory and the site doesn't run correctly because of the missing DLL.
NuGet 打算如何用于这种场景?我想签入 Bin 目录中的 Elmah.dll 吗?
How is NuGet intended to be used in this kind of scenario? Am I suppose to check in Elmah.dll in the Bin directory?
推荐答案
这是基于上面GC.的解决方案.添加一个类库 (csproj) 并在网站项目中引用该类库.将 nuget 包添加到类库中.在类库中,实际上是引用了某个类文件中的nuget包.也许创建一个一次性实例或其他东西.您可以使用包中包含的任何类.这会强制将 .dll 复制到网站项目中的 Bin 目录.
This is based on GC.'s solution above. Add a class library (csproj) and reference that class library in the website project. Add the nuget packages to the class library. In the class library, actually reference the nuget packages in some class file. Maybe create a throwaway instance or something. You can use any class that's contained in the package. This forces the .dll to be copied to the Bin directory in the web site project.
这篇关于在 ASP.NET“网站"中使用带有 *.dll.refresh 文件的 NuGet带有 Web 部署项目的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!