鉴于以下TT宏:如何从宏TT引用装配
<#@ template debug="false" hostspecific="true" language="C#" #>
<#@ output extension=".xml" #>
<#@ assembly name="$(TargetPath)" #>
<#@ import namespace="System.Reflection" #>
<#
AssemblyInfoHelper assemblyInfo = new AssemblyInfoHelper(Assembly.LoadFrom(@"H:\My Projects\TestApp\bin\Windows Phone\Debug\TestApp.dll"));
#>
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
...
</Deployment>
...我想加载使用$(TARGETPATH)内容组装,而不是硬编码组件的全路径......这可能吗?
任何帮助,非常感谢:-)
感谢 J3D
在此处讨论了一些解决方法/示例:http://weblogs.asp.net/lhunt/archive/2010/05/04/t4-template-error-assembly-directive-cannot-locate-referenced- assembly-in-visual-studio-2010-project.aspx ...认为你需要使用类似于“$(TargetDir)MyAssembly.dll”的文件 – 2012-08-11 19:51:57
<#@程序集名称=“$(TargetPath)”#>已经包含需要引用的程序集的完整路径...我正在寻找的是一种方法来替换指令下面代码中的硬编码路径:Assembly.LoadFrom(@“H:\ My Projects \ TestApp \ bin \ Windows Phone \ Debug \ TestApp.dll“)应该是像Assembly.LoadFrom(”$(TargetPath)“) - 当然,这是行不通的:-( – j3d 2012-08-11 22:30:44
也许使用VCConfiguration.Evaluate .... http:///msdn.microsoft.com/en-us/library/microsoft.visualstudio.vcprojectengine.vcconfiguration.evaluate.aspx .... http://stackoverflow.com/ques tions/8477011/how-to-get-expanded-path-from-envdte-vcprojectengine .....或访问DTE接口..... http://stackoverflow.com/questions/3408159/using-types- t4-template-that-exist-in-the-the-project-as-the-template – 2012-08-11 22:43:48