我的解决方案包括这两个项目:
- MyNamespace.Web.UI
- MyNamespace.Web.Core
UI 引用 Core,而 Core 引用 Foobar.dll,除了我的库之外,它不存在于任何地方。当我从 Visual Studio 2008 构建时,Foobar.dll 按预期位于 UI 项目的 Bin 文件夹中。我已经确定它在构建之前不存在。
但是当我从 NAnt 构建时,它不存在,这会导致运行时异常。 NAnt 任务如下所示:
<target name="compile" depends="init">
<exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
commandline="${solution.file} /m /t:Clean /p:Configuration=${project.config} /v:q" workingdir="." />
<exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe"
commandline="${solution.file} /m /t:Rebuild /p:Configuration=${project.config} /v:q" workingdir="." />
</target>
在VS中我尝试过构建、重建、在 Release模式和 Debug模式下重建等等。它总是一样的。 Foobar.dll 位于 Bin 文件夹中。 NAnt 则不然。我还尝试从 NAnt 脚本中删除/m 开关。结果相同。
Core 中引用了其他几个 dll,而 UI 中没有引用,它们在 NAnt 构建后按预期出现在 Bin 中。
我的解决方法是在 UI 项目中引用 Foobar.dll,但这让我有点恶心。知道什么会导致这种情况吗?
(顺便说一句,Foobar.dll实际上是NHibernate.ProxyGenerators.CaSTLeDynamicProxy.dll)
最佳答案
您可能可以在 VS 中选择“复制本地”,这隐式地在构建之前将其复制到本地。您需要在 NAnt 中模拟这一点。
与为什么您可以从 Visual Studio 中为 Web 项目执行“发布”类似,但对于命令行,您必须构建然后将输出复制到您要去的任何地方。
关于visual-studio-2008 - 通过 NAnt 与 Visual Studio 构建 - 缺少一个 dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/270479/