【问题标题】:Visual Studio 2015, T4 template: Assembly directive does not use Shadow CopyingVisual Studio 2015,T4 模板:Assembly 指令不使用影子复制
【发布时间】:2016-12-22 16:57:51
【问题描述】:

重建解决方案时,我收到错误消息:-

Error       Unable to copy file "obj\Debug\TargetTest.dll" to "bin\Debug\TargetTest.dll". The process cannot access the file 'bin\Debug\TargetTest.dll' because it is being used by another process.    

当我删除程序集指令时,解决方案会重建:-

<#@ template debug="true" hostspecific="false" language="C#" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="C:\\Code\\T4Template\\bin\\Debug\\TargetTest.dll" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Text" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Reflection" #>
<#@ output extension=".cs" #>

如何解决这个问题?我猜这与visual studio中的影子复制配置有关,但我找不到它。

【问题讨论】:

    标签: .net visual-studio-2015 t4 shadow-copy


    【解决方案1】:

    T4设计时模板在Visual Studio的同一进程下在不同的App域中处理。重建解决方案时,Visual Studio 会尝试替换引用的 DLL,但它无法替换它,因为它仍在使用中。

    我通过删除处理 T4 模板的 AppDomain 来解决此问题。见msdn

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多