CAR*_*OTH 10 t4 visual-studio-2010
我正在尝试运行一个打开XML文件的T4模板,并使用它来生成代码工件.但是,当我尝试运行类似于下面的T4模板时,我收到一条错误消息
<#@ template debug="false" hostspecific="false" language="C#" #>
<#@ assembly name="System.Xml.dll" #>
<#@ assembly name="System.Xml.Linq.dll" #>
<#@ import namespace="System.IO" #>
<#@ import namespace="System.Xml" #>
<#@ import namespace="System.Xml.Linq" #>
<#@ output extension=".cs" #>
namespace ConsoleApplication1
{
<# XElement fragment = XElement.Load("data.xml"); #>
...
Run Code Online (Sandbox Code Playgroud)
Visual Studio 2010错误列表显示以下消息
Running transformation: System.IO.FileNotFoundException: Could not find file 'C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\data.xml'.
It is trying to open the file on the path where the TextTemplateFileGenerator custom tool runs. I'd like it to open the file relative to my project path, because other developers on my team use different folder structures. Does anyone know if it is something possible to accomplish?
Ole*_*ych 22
将template指令中的hostspecific选项更改为"true"并调用Host.ResolvePath("data.xml").
| 归档时间: |
|
| 查看次数: |
4941 次 |
| 最近记录: |