T4MVC "run custom tool" generates EnvDTO 7.0 vs 8.0 csc warning
I'm getting the following warning when I right click on T4MVC.tt and select "run custom tool" (i.e. rebuild by T4MVC.cs file).
Warning 1 Compiling transformation: Assuming assembly reference 'EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' mat开发者_如何学编程ches 'EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a', you may need to supply runtime policy C:\Development\EHealth-Trunk\src\EHealth.Web\T4MVC.tt 1 1
It's no big deal really, I just don't like to have (unnecessary) warnings in my code-base...
I haven't quite figured out what the problem is, but I did isolate it to a small repro where this happens:
<#@ template language="C#" #>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="VSLangProj" #>
<#+
void Test(EnvDTE.Project Project) {
var vsProject = (VSLangProj.VSProject)Project.Object;
var refs = vsProject.References;
}
#>
Which gets the following warning during processing:
Compiling transformation: Assuming assembly reference 'EnvDTE, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' matches 'EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a', you may need to supply runtime policy
The only EnvDTE in my GAC is 8.0.0.0. It seems that the problem relates to the fact that VSLangProj 7.0.3300.0 (the only one I have) has a reference to EnvDTE 7.0.3300.0, which doesn’t exist.
Clearly, this is not an 'answer' quite yet, but it's the beginning of the investigation :)
Change:
<#@ assembly name="EnvDTE" #>
To:
<#@ assembly name="EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" #>
in T4MVC.tt and it will remove the compiler warning :)
David - I'm going to submit a pull request with the fix to MvcContrib soon - just let me know that you are happy with that solution before I do it :)
Add app.config and paste this code below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1" appliesTo="v2.0.50318">
<dependentAssembly>
<assemblyIdentity name="EnvDTE" publicKeyToken=
"b03f5f7f11d50a3a"/>
<bindingRedirect oldVersion="7.0.3300.0"
newVersion="8.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
精彩评论