none
Transforming T4 template on build intermittently produces an exception RRS feed

  • Question

  • Hi all,

    I'm using 

    <PropertyGroup>
     <TransformOnBuild>True</TransformOnBuild> 
     <OverwriteReadOnlyOutputFiles>true</OverwriteReadOnlyOutputFiles>
     <TransformOutOfDateOnly>false</TransformOutOfDateOnly>
    </PropertyGroup>

    to transform all templates in the project upon building. This works most of the time, however, sometimes it throws this:

    error : An Exception was thrown while processing a directive named 'Dsl'. The transformation will not be run.  The following Exception was thrown: [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Modeling.Sdk.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : File name: 'Microsoft.VisualStudio.Modeling.Sdk.15.0, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error :    at Microsoft.VisualStudio.Modeling.DslDefinition.DslDirectiveProcessorBase.GeneratePostInitializationCode(String directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider, IDictionary`2 requiresArguments, IDictionary`2 providesArguments) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error :    at Microsoft.VisualStudio.Modeling.DslDefinition.DslDirectiveProcessor.GeneratePostInitializationCode(String directiveName, StringBuilder codeBuffer, CodeDomProvider languageProvider, IDictionary`2 requiresArguments, IDictionary`2 providesArguments) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error :    at Microsoft.VisualStudio.TextTemplating.RequiresProvidesDirectiveProcessor.ProcessDirective(String directiveName, IDictionary`2 arguments) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error :    at Microsoft.VisualStudio.TextTemplating.Engine.ProcessCustomDirectives(ITextTemplatingEngineHost host, TemplateProcessingSession session, ITelemetryScope scope, IEnumerable`1 directivesToBeProcessed) [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error :  [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : WRN: Assembly binding logging is turned OFF. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : Note: There is some performance penalty associated with assembly bind failure logging. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]
    error : . Line=4, Column=4 [C:\Source\Trunk\Projects\Driver.Design.Package\Driver.Design.Package.csproj]

    I rebuilt this project 1000 times overnight, and it threw this exception twice. It normally wouldn't be a problem, but this project will be part of a TFS build pipeline, and I wouldn't want this to cause any failures.

    Considering it builds 99% of the time, I'm pretty lost on what could be the cause of this.

    • Moved by CoolDadTx Monday, October 28, 2019 2:04 PM VS related
    Monday, October 28, 2019 9:25 AM

All replies

  • Hello,

    Have you tried closing then reopening Visual Studio to see if the issue persist? 

    Also, you can report this issue via the feedback button in the title bar of Visual Studio to get direct attention to the abnormally happening here. 


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Monday, October 28, 2019 10:50 AM
  • I tried building this with VisualStudio and with msbuild from command prompt separately. Restarted machine in between - it occurs either way. I will report it, thanks for that suggestion.

    Interestingly, this never occurs when you just save the template and it gets transformed, only when it is done on build.

    Monday, October 28, 2019 11:36 AM
  • Hi binginsin,

    Welcome to the MSDN forum.

    How did you import the Microsoft.TextTemplating.targets in the csproj file when you build your project? 

    Make sure that you have installed the Modeling SDK.

    Usually, you should add this in your csproj to transform your text template:

    <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v16.0\TextTemplating\Microsoft.TextTemplating.targets" />

    >>You can refer to this article about regenerating the code automatically.

    ## install the missing DLLs "Microsoft.VisualStudio.Modeling.Sdk.15.0.dll" into the GAC using gacutil.

    Also, check the versions of your assembly references are the same as your OS version.

    Besides,  Click  Start >Run and type REGEDIT

    Then go to HKEY_Local_Machine\Software\Microsoft\Fusion and change the key EnableLog to 1. 

    ###l have tried to reproduce this issue in my side. Create a project and then add a text template file with some easy code in the project. Then add the nodes which will transform all templates when build in proj file. It turns that without any error when build. If l have lose some key steps or you have any other useful information you forgot,please let us know.

    Any feedback will be expected.

    Best Regards,

    Perry


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com



    Tuesday, October 29, 2019 3:33 AM
  • Hello,

    Begin getting similar errors since have installed Studio 2019 Community.

    Randomly fail on build when have 40+ projects in solution.

    Manual rebuild of failed project fix the situation... till next fail.

    Do not have this problem when do build-per-project (project modified to use DLL's only and required DLL's copied into \Bin\Debud) on CI.

    Best regards,

    Andrey


    Sincerely, Highly skilled coding monkey.

    Friday, December 13, 2019 9:48 AM