T4MVC "run custom tool" generates EnvDTO 7.0 vs 8.0 csc warning
Asked Answered
D

3

11

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' matches '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...

Delisle answered 26/7, 2011 at 0:37 Comment(1)
Yep, this has been an annoyance for a while, and I was never sure exactly what caused it. Maybe it's time I investigate it a bit deeper!Selfgoverned
S
3

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 :)

Selfgoverned answered 26/7, 2011 at 18:41 Comment(2)
The part that I think will help us is "you may need to supply runtime policy" which is covered (too briefly) here: msdn.microsoft.com/en-us/library/wc57zasf%28v=VS.90%29.aspx - they say something about forcing 'unification by using directives in the application .config file'...Delisle
The fact that the template runs without errors shows that the proper policies are in place. The problem is that the compiler doesn't know that. Another approach might be to use a pragma to try to remove the warning, but I wan't able to make that work. :(Selfgoverned
D
2

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 :)

Delisle answered 27/7, 2011 at 7:27 Comment(4)
Ignore this answer for now... I'm not sure it actually works (sorry).Delisle
Sorry, I just noticed this. Let me know if you get something working!Selfgoverned
I'm not sure if this does anything useful or not... It seems to show the warning until you edit the T4MVC.tt file and hit save (which i presume triggers the tt compiler) then the warning goes away...Delisle
Yes, it probably doesn't work. It's a pretty tough issue, and I couldn't get anyone at MS to find a workaround :(Selfgoverned
E
1

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>

Ethic answered 11/7, 2013 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.