运行时出现T4错误,但调试时未出现错误

时间:2016-10-12 14:27:02

标签: .net t4 nswag

我尝试使用NSwag编写.tt文件,当我运行自定义工具时,出现此错误:

  

运行转换:System.IO.FileNotFoundException:无法加载文件或程序集' NSwag.CodeGeneration,Version = 6.6.6124.16498,Culture = neutral,PublicKeyToken = null'或其中一个依赖项。该系统找不到指定的文件。   文件名:' NSwag.CodeGeneration,Version = 6.6.6124.16498,Culture = neutral,PublicKeyToken = null'

     

在[0]处重新抛出异常:
     在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)
     在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData,Int32 type)
     在NSwag.CodeGeneration.SwaggerGenerators.WebApi.WebApiAssemblyToSwaggerGenerator.WebApiAssemblyLoader.GenerateForController(String controllerClassName,String settingsData)
     在C:\ projects \ nswag \ src \ NSwag.AssemblyLoader \ SwaggerGenerators \ WebApi \ WebApiAssemblyToSwaggerGenerator.cs:第59行的NSwag.CodeGeneration.SwaggerGenerators.WebApi.WebApiAssemblyToSwaggerGenerator.GenerateForController(String controllerClassName)中

但是,当我调试模板时,我没有。它运行正常。

为什么T4模板会运行调试而不是正常运行?

以下是我尝试的内容:

  • 确保文件(及相关文件)未设置为Read-Only
  • 检查.dll文件的安全设置。 ALL APPLICATION PACKAGESUsers现在已完全控制。
  • 尝试将DLL移至C:\Temp\

仍然无法工作。

(这不是关于FileNotFoundException的问题,我理解这意味着什么。)

这是.tt文件的开头:

<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ output extension=".cs" #>
<#@ include file="T4Toolbox.tt" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Runtime" #>
<#@ assembly name="System.ObjectModel" #>
<#@ assembly name="C:\Program Files (x86)\Rico Suter\NSwagStudio\NJsonSchema.dll" #>
<#@ assembly name="C:\Program Files (x86)\Rico Suter\NSwagStudio\NJsonSchema.CodeGeneration.dll" #>
<#@ assembly name="C:\Program Files (x86)\Rico Suter\NSwagStudio\NSwag.Core.dll" #>
<#@ assembly name="C:\Program Files (x86)\Rico Suter\NSwagStudio\NSwag.CodeGeneration.dll" #>
<#@ assembly name="C:\Program Files (x86)\Rico Suter\NSwagStudio\NSwag.AssemblyLoader.dll" #>

<#@ import namespace="NSwag.CodeGeneration" #>

<#@ import namespace="System.IO" #>
<#@ import namespace="System.Linq" #>
<#@ import namespace="System.Reflection" #>
<#@ import namespace="Microsoft.CSharp" #>
<#@ import namespace="NSwag" #>
<#@ import namespace="NSwag.CodeGeneration.SwaggerGenerators" #>
<#@ import namespace="NSwag.CodeGeneration.SwaggerGenerators.WebApi" #>
<#@ import namespace="NSwag.CodeGeneration.Utilities" #>
<#@ import namespace="NSwag.Collections" #>

0 个答案:

没有答案