获取引用的项目在T4模板路径? [英] Get referenced project's path in T4 template?

查看:1083
本文介绍了获取引用的项目在T4模板路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在它有几个项目的解决方案。我想在我的测试项目,以基于在另一个项目code测试的一个创造一些T4模板。测试项目有一个项目引用其他项目。我的问题是,我不知道如何得到一个文件路径文件EDMX我需要生成从code。

I have a solution that has a few projects in it. I'd like to create some T4 templates in one of my test projects to generate tests based on code in another project. The test project has a Project Reference to the other project. The problem I have is that I don't know how to get a file path to the edmx file I need to generate code from.

示例(pretend这是一种基于ASCII的解决方案浏览器):

Example (pretend this is an ASCII-based Solution Explorer):

MySolution.sln
-> MyTests.csproj (C:\a\b\c\)
----> GeneratedTests.tt (C:\a\b\c\GeneratedTests.tt)
-> MyDAL.csproj (C:\x\y\z\)
----> MyModel.edmx (C:\x\y\z\MyModel.edmx)

如何将我的GeneratedTests.tt能够得到一个文件路径MyModel.edmx利用它其项目的参考?

How would my GeneratedTests.tt be able to get a file path for MyModel.edmx utilizing its project reference to it?

推荐答案

这不工作的方式。你必须引用由路径的dll(你可以找到与出 Host.ResolvePath ,并使用 VolatileAssembly 从工具箱标签可以重新编译它无需重新启动VS),并使用反射来在模型工作。

This doesn't work that way. You'll have to reference the dll by path (you can find that out with Host.ResolvePath and use the VolatileAssembly tag from the toolbox to be able to recompile it without restarting VS ) and use reflection to work on the Model.

这篇关于获取引用的项目在T4模板路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆