none
T4 templates not working with portable assembly references in Visual Studio 2015 Update 2

    Question

  • After upgrade the VS 2015 to update 2. The OData client code generator T4 template which reference the Microsoft.OData.Edm library no longer be able to generate code. The Microsoft.OData.Edm.dll is a portable library.

    Is there anyone know how to solve this issue?

    The error stack:

    Severity Code Description Project File Line Suppression State
    Error Compiling transformation: The type 'Func<,>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

    Error Compiling transformation: The type 'XmlReader' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

    Error Compiling transformation: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

    Error Compiling transformation: Operator '!=' cannot be applied to operands of type 'method group' and ''

    Error Compiling transformation: foreach statement cannot operate on variables of type 'System.Collections.Generic.IEnumerable' because 'System.Collections.Generic.IEnumerable' does not contain a public definition for 'GetEnumerator'

    Error Compiling transformation: The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

    Error Compiling transformation: foreach statement cannot operate on variables of type 'System.Collections.Generic.IEnumerable' because 'System.Collections.Generic.IEnumerable' does not contain a public definition for 'GetEnumerator'

    Error Compiling transformation: foreach statement cannot operate on variables of type 'System.Collections.Generic.IEnumerable' because 'System.Collections.Generic.IEnumerable' does not contain a public definition for 'GetEnumerator'

    Error Compiling transformation: foreach statement cannot operate on variables of type 'System.Collections.Generic.IEnumerable' because 'System.Collections.Generic.IEnumerable' does not contain a public definition for 'GetEnumerator'

    Error Compiling transformation: Operator '==' cannot be applied to operands of type 'method group' and 'string'

    Error Compiling transformation: foreach statement cannot operate on variables of type '?' because '?' does not contain a public definition for 'GetEnumerator'

    Error Compiling transformation: The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes'.

    Wednesday, April 27, 2016 10:21 AM

Answers

  • Hi laylaliu,

    Thanks for your detailed steps and I tried with your steps getting the same result. And I also tested in Visual Studio 2015 Update 1, everything is ok.

    I'm afraid this issue is caused by Visual Studio 2015 Update 2. I suggest you submit this issue to Visual Studio Connect and share the feedback link here. I will vote it and it also can let other communities to vote and add comments for your feedback. I think the report team will treat this issue seriously. Thanks for your feedback for Visual Studio product.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 02, 2016 1:56 AM
    Moderator

All replies

  • Hi laylaliu,

    Could you share your operation steps about when do you get this error message? I create a sample project with following steps and generate code successfully. Please check whether there has any difference with you, please feel free to let me know.

    1. Install OData v4 Code Generator from this link.
    2. Create a sample Console application and add a OData Client.
    3. It generate two files of .tt and .ttinclude successful.

    According to the error message, the problem seems caused by a missing assembly. Please check your references in your project with following screenshot, whether there has any assembly are missing.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, April 28, 2016 7:23 AM
    Moderator
  • Hi Weiwei,

    Your steps are correct but not finished. All steps are as following:

    1. Install OData v4 Code Generator from this link.
    2. Create a sample Console application and add a OData Client.
    3. It generate two files of .tt and .ttinclude successful.
    4. Open the newly added .tt file. and update line 9 from
       public const string MetadataDocumentUri = "";
       to
       public const string MetadataDocumentUri = "http://services.odata.org/V4/(S(wnsff13weenvazh4koqspaow))/TrippinServiceRW/";
    5. Ctrl+Save this tt file.

    It will shows those errors in the "Error List" window.

    Expected : A well structured class file should be generated.

    Friday, April 29, 2016 1:44 AM
  • Hi laylaliu,

    Thanks for your detailed steps and I tried with your steps getting the same result. And I also tested in Visual Studio 2015 Update 1, everything is ok.

    I'm afraid this issue is caused by Visual Studio 2015 Update 2. I suggest you submit this issue to Visual Studio Connect and share the feedback link here. I will vote it and it also can let other communities to vote and add comments for your feedback. I think the report team will treat this issue seriously. Thanks for your feedback for Visual Studio product.

    Best Regards,
    Weiwei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, May 02, 2016 1:56 AM
    Moderator