2016-08-16 40 views
0

當重建解決方案,我得到錯誤信息: -的Visual Studio 2015年,T4模板:裝配指令不使用的卷影拷貝

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" #> 

如何解決這個問題?我想這與視覺工作室中的影子複製配置有關,但我找不到它。

回答

0

T4設計時間模板在Visual Studio的同一進程下在不同的App域中處理。當重建解決方案時,Visual Studio會嘗試替換引用的DLL,並且它無法替換它,因爲它仍在使用中。

我通過刪除處理T4模板的AppDomain來解決此問題。見msdn