locked
STE T4 templates and TFS 2010 RRS feed

  • Question

  • I've been using the STE templates and TFS 2010 and though I like both a lot, I have trouble using them together.

    The problem is when the templates "re-run" to regenerate their code. Not all of the files they write get marked as checked-out and it causes problems. It seems to know to check out files that are prefixed with the templates name.

    So for example if my T4 template is called STE.Types.tt then there's no problem w/ the STE.Types.cs file it makes...but the other files it makes for each entity don't automatically get checked out when the template re-runs, they stay read-only and the process fails.

    I don't know if this is a problem w/ TFS or the templates. Would maybe changing the T4 templates to generate file names for the entities that were also prefixed w/ the te,plate name work?

    Like STE.Entity1.cs, STE.Entity2.cs, etc. I'd kind of like that anyway because it makes it easy to see that they are all STE files.

    Thanks for any considerations or other options to make the process smoother.
    Saturday, February 6, 2010 7:19 AM

Answers

  • Ah, yes, this is the CTP on Beta2.  In this version we didn't have any integration with the Source Code Control system.  In newer releases this is fixed.   As a workaround till you get a newer release, you can check them out manually.

    -jeff
    • Marked as answer by emanon Tuesday, February 9, 2010 9:58 PM
    Tuesday, February 9, 2010 8:29 PM
    Moderator

All replies

  • Thanks for taking the time check out STEs and provide feedback.

    I am wondering if a little explanation might clear this up, if not please let me know.  Unlike many .tt files, the STE .tt files generate multiple files from the single .tt file.  The T4 VS SingleFileGenerator (SFG) always creates one file that is the same base name as the template (Joe.tt => Joe.txt or Joe.tt => Joe.cs)  you can't prevent that as long as you are using the custom tool TextTemplatingFileGenerator to transform your template.  The other files generated by the STE .tt files are generated by the EntityFrameworkTemplateFileManager.  The T4 SFG will open your file for edit anytime you run it.  On the other hand, the EntityFrameworkTemplateFileManager only opens your file for edit, and writes to the file if the contents of the file have actually changed.

    Is the behavior that I am describing the behavior that you are seeing?  If not, can you describe in more detail (error messages, etc) the problems that you are seeing?  Can you provide the steps to reproduce the problem?

    Thanks,
    -jeff

    Tuesday, February 9, 2010 7:08 PM
    Moderator
  • Jeff,

    Thanks for the reply and information.

    I believe the problem I'm seeing is that when I modify my EDMX file and save (and it tries to regenerate some/all of the entity.cs files) it fails to check the existing files out of TFS and so the process fails.

    Below is an example of the error I will get unless I manually delete the previously generated entity files:

    Error 1 Running transformation: System.UnauthorizedAccessException: Access to the path 'C:\Dev\VendorContracts\Src\Main\VendorContracts\VendorContracts\Models\EF\ContractLicense.cs' is denied.
       at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
       at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath)
       at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
       at System.IO.StreamWriter.CreateFile(String path, Boolean append)
       at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
       at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
       at System.IO.File.InternalWriteAllText(String path, String contents, Encoding encoding)
       at System.IO.File.WriteAllText(String path, String contents)
       at Microsoft.VisualStudio.TextTemplatingFA78FF8FCE7E07BBB8B48632DDC6D92F.GeneratedTextTransformation.VSTemplateFileManager.CreateFile(String fileName, String content)
       at Microsoft.VisualStudio.TextTemplatingFA78FF8FCE7E07BBB8B48632DDC6D92F.GeneratedTextTransformation.TemplateFileManager.WriteFiles()
       at Microsoft.VisualStudio.TextTemplatingFA78FF8FCE7E07BBB8B48632DDC6D92F.GeneratedTextTransformation.TransformText()
       at Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession session, String source, ITextTemplatingEngineHost host, String& result)  1 1 
    • Edited by emanon Tuesday, February 9, 2010 7:58 PM typos
    Tuesday, February 9, 2010 7:57 PM
  • Ah, yes, this is the CTP on Beta2.  In this version we didn't have any integration with the Source Code Control system.  In newer releases this is fixed.   As a workaround till you get a newer release, you can check them out manually.

    -jeff
    • Marked as answer by emanon Tuesday, February 9, 2010 9:58 PM
    Tuesday, February 9, 2010 8:29 PM
    Moderator
  • Excellent. I'm very glad this has been fixed already.

    Thanks.
    Tuesday, February 9, 2010 9:59 PM