locked
Storing extension data RRS feed

  • Question

  • I'm working on an extension in which I generate assemblies at run-time. In the development environment this works ok as I can use the default bin\Debug folder but what is the correct place to store such data?

    Wednesday, May 12, 2010 7:16 PM

Answers

  • Hi Sander,

    Based on my understanding, you call the T4 service that is available inside VS directly to transform the files, and is then compiling the output. This is perfectly ok, but it isn’t a standard scenario so we don’t really have a particular T4-specific recommendation about where to save the output. If there is any standard VS guidance about where to save temporary user files,  after I consulted with senior engineer in T4, I’d suggest you follow those:

    If there isn’t any specific guidance, then have a look at the environment variable “temp”. This seems to point to a user-specific temporary directory e.g. “C:\Users\DUNCAN~1.EUR\AppData\Local\Temp”. When T4 saves temporary output to disc (which it can do to help debugging), this is where it saves it to.


    Depending on what you are trying to achieve, you might be interested in the new pre-processing feature in VS2010. If you are processing templates supplied by the end user, then pre-processing won’t be of use to you. However, if you are using a fixed set of templates embedded in your application, then you might be able to use pre-processed templates instead. Essentially, pre-processing produces a normal class file that can be called at runtime to generate output. See http://www.olegsych.com/2009/09/t4-preprocessed-text-templates/ for more info.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Monday, May 31, 2010 2:35 AM
    Wednesday, May 19, 2010 2:27 AM
  • Hi Sander,

    If you want to get the path of user-specific temporary files, you can use GetTempPath Function. And for your reference, please see: Storing User-Specific Information.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, May 21, 2010 7:43 AM

All replies

  • Hi Sander,

    Thanks for your post.

    I have read your thread carefully, but I'm not sure I undertood you clearly, Could you tell me more detailed? Is this extension is Visual Studio Extension? Such as Macro, Addin or VSPackage? 

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Thursday, May 13, 2010 5:30 AM
  • Ok I'll try to clarify. The extension is a VS2010 Extension (VSIX).

    Within this extension I parse T4 templates and compile them to assemblies, 1 per T4 template (.tt file) and I want to store these assemblies on disk to prevent re-parsing of the templates every time to prevent performance hits.

    For example:

    I have 2 T4 templates template1.tt and template2.tt

    These will be compiled to:

    template1.dll and template2.dll

    Now my question is, where can I store these assemblies? C:\temp seems a no-go and so are a few other locations like that.

    What is the recommended place to store files?

    Thursday, May 13, 2010 10:41 AM
  • Hi Sander,

    Based on my understanding, you call the T4 service that is available inside VS directly to transform the files, and is then compiling the output. This is perfectly ok, but it isn’t a standard scenario so we don’t really have a particular T4-specific recommendation about where to save the output. If there is any standard VS guidance about where to save temporary user files,  after I consulted with senior engineer in T4, I’d suggest you follow those:

    If there isn’t any specific guidance, then have a look at the environment variable “temp”. This seems to point to a user-specific temporary directory e.g. “C:\Users\DUNCAN~1.EUR\AppData\Local\Temp”. When T4 saves temporary output to disc (which it can do to help debugging), this is where it saves it to.


    Depending on what you are trying to achieve, you might be interested in the new pre-processing feature in VS2010. If you are processing templates supplied by the end user, then pre-processing won’t be of use to you. However, if you are using a fixed set of templates embedded in your application, then you might be able to use pre-processed templates instead. Essentially, pre-processing produces a normal class file that can be called at runtime to generate output. See http://www.olegsych.com/2009/09/t4-preprocessed-text-templates/ for more info.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Nancy Shao Monday, May 31, 2010 2:35 AM
    Wednesday, May 19, 2010 2:27 AM
  • Thank you for your answer. I was looking for guidance specific to Visual Studio.

    I have no problem at all with the T4 templates and I'm already using the pre-processing feature of VS2010 but in a non-standard (and what I can read not supported) way ;)

    I'll try to save to the path you specified, is there any method in the Visual Studio or Windows SDK to obtain this path?

    Wednesday, May 19, 2010 12:11 PM
  • Hi Sander,

    If you want to get the path of user-specific temporary files, you can use GetTempPath Function. And for your reference, please see: Storing User-Specific Information.

    Regards,

    Nancy Shao [MSFT]
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg @ microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, May 21, 2010 7:43 AM