在发布时突然没有复制引用的程序集(DLL)

Nic*_*ick 8 .net visual-studio servicestack ormlite-servicestack

在Web项目发布期间,我遇到了一个引用库(ServiceStack.OrmLite)部署的奇怪问题.这是工作正常,直到最后一周左右,而现在突然有些ServiceStack的DLL不被当项目发布到本地文件系统,FTP或Web部署,从Visual Studio或MSBuild的复制.

OrmLite引用通过nuget添加到类lib项目中.类lib项目引用被添加到主Web App项目中.当我发布Web App项目时,它编译并复制除五个ServiceStack.OrmLite DLL中的三个(即ServiceStack.Common,ServiceStack.Interfaces和ServiceStack.Text未复制)之外的所有文件.我已经检查(甚至重置)所有DLL引用的'Copy Local'属性为'true',但问题仍然存在.我还检查过OrmLite未在GAC注册.

任何提示或建议表示赞赏.

更新1:

我遇到了一堆与同一问题相关的帖子(但特别是ServiceStack没有).似乎Visual Studio和msbuild [正确地]在发布期间忽略项目中的任何间接引用.

以下是我遇到的一些解决方案:

  1. 也参考主项目中的程序集.

  2. 使用构建脚本将DLL复制为构建后事件.

  3. 向类lib添加一个虚拟(模拟)方法,并从发布期间未复制的程序集或命名空间中实例化任何类.我选择了这个选项,它部分地解决了这个问题.现在,ServiceStack.Common和ServiceStack.Text被复制,但ServiceStack.Interfaces仍然没有被复制,即使我已经创建了一个'ServiceStack.Logging.LogManager'的模拟实例,它是ServiceStack.Interfaces的一部分.所以,基本上我还是卡住了.

Raf*_*ael 0

你可以试试这个答案

基本上,将相应的内容添加<dependentAssembly>到您的{web|app}.config

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="ServiceStack.Common" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-3.9.70.0" newVersion="3.9.70.0" />
          </dependentAssembly>
       </assemblyBinding>
    </runtime>
</configuration>
Run Code Online (Sandbox Code Playgroud)