"Cannot find file" error during T4 template compilation

2

I've customized a T4 template in Visual Studio 2012, and while building I'm getting the following error message:

Error 54 Running transformation: System.Runtime.InteropServices.COMException (0x80004005): Cannot find file "E:\xxx\yyy\zzz\Sqlite\SqliteUser.cs".

Server stack trace: 
   at EnvDTE.ProjectItems.AddFromFile(String FileName)
   at Microsoft.VisualStudio.TextTemplatingEC6A2B3A41C616DAF7A733C5085314E2C3F5CE23DBE80E719FD33995883D5E510F37A17C37D9079D1256CDE20C927D612B6A821F33CC97A0D9F806591BA9D314.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager.ProjectSync(ProjectItem templateProjectItem, IEnumerable`1 keepFileNames)
   at Microsoft.VisualStudio.TextTemplatingEC6A2B3A41C616DAF7A733C5085314E2C3F5CE23DBE80E719FD33995883D5E510F37A17C37D9079D1256CDE20C927D612B6A821F33CC97A0D9F806591BA9D314.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager.<.ctor>b__6a(IEnumerable`1 keepFileNames)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
   at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
   at System.Action`1.EndInvoke(IAsyncResult result)
   at Microsoft.VisualStudio.TextTemplatingEC6A2B3A41C616DAF7A733C5085314E2C3F5CE23DBE80E719FD33995883D5E510F37A17C37D9079D1256CDE20C927D612B6A821F33CC97A0D9F806591BA9D314.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager.Process(Boolean split)
   at Microsoft.VisualStudio.TextTemplatingEC6A2B3A41C616DAF7A733C5085314E2C3F5CE23DBE80E719FD33995883D5E510F37A17C37D9079D1256CDE20C927D612B6A821F33CC97A0D9F806591BA9D314.GeneratedTextTransformation.TransformText() E:\xxx\yyy\zzz\SqliteDataModel.tt

The error is for line 1, column 1 of the file, so it's not directing me to a specific location in it. The file referenced within the error - "SqliteUser.cs" - is one of many files created by the template, and there's no error for the other files. The result of this error is having "Source file xxx could not be found" errors for each of the files generated from the T4 template.

When I try to debug the T4 template from the solution explorer's context menu, I'm getting the following exception:

System.Runtime.InteropServices.COMException was unhandled by user code
  HResult=-2147417846
  Message=The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
  Source=EnvDTE
  ErrorCode=-2147417846
  StackTrace:
       at EnvDTE.ProjectItem.get_FileNames(Int16 index)
       at Microsoft.VisualStudio.TextTemplatingEC6A2B3A41C616DAF7A733C5085314E2C3F5CE23DBE80E719FD33995883D5E510F37A17C37D9079D1256CDE20C927D612B6A821F33CC97A0D9F806591BA9D314.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager.ProjectSync(ProjectItem templateProjectItem, IEnumerable`1 keepFileNames) in c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude:line 2199
       at Microsoft.VisualStudio.TextTemplatingEC6A2B3A41C616DAF7A733C5085314E2C3F5CE23DBE80E719FD33995883D5E510F37A17C37D9079D1256CDE20C927D612B6A821F33CC97A0D9F806591BA9D314.GeneratedTextTransformation.EntityFrameworkTemplateFileManager.VsEntityFrameworkTemplateFileManager.<.ctor>b__6a(IEnumerable`1 keepFileNames) in c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\Extensions\Microsoft\Entity Framework Tools\Templates\Includes\EF.Utility.CS.ttinclude:line 2169
       at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
       at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
  InnerException: 

I'm not sure if it's related, but it certainly doesn't help... After executing "Run custom tool" from the solution's explorer (sometimes once, sometime twice...) all these errors disappear, but it's still far from a pleasant development experience.

Any ideas?

visual-studio-2012
t4
asked on Stack Overflow May 26, 2013 by ury

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0