locked
Adding item template to a Solution folder RRS feed

  • Question

  • Any idea on how to add an Item template's output to a Solution folder just like what happens when the Test project is created and test settings file is added to solution folder.

    Ajeeth Kumar.A, Cognizant

    Friday, September 7, 2012 4:54 PM

Answers

  • This because you file template is a project item template.

    I suppose your item template belongs to specific type of project (like C# library), that why i can't be added to a solution folder.

    For exemple, when you try to add a new item to a solution folder using Visual Studio, you'll only see project items that are in General Category. All those files are not "templates", they can be find here : Microsoft Visual Studio 10.0 install dir\Common7\IDE\NewFileItems

    Only (in my case) testsettings uses a template.

    Could you please provide the vstemplate code of your item template, or try to adapt to remove project type dependency

    • Marked as answer by Ego Jiang Thursday, September 20, 2012 9:26 AM
    Thursday, September 13, 2012 7:47 AM

All replies

  • Hi Aieeth,

    Test project is a project template. An Item template is an item added into the project. It has not the output property. Do you mean to add a project template and want its output path is the solution folder?

    If yes, you just need to set the output path as "..\".

    If you have any concerns about this issue, please feel free to let us know.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Monday, September 10, 2012 6:30 AM
  • Hi Ego,

    What I meant by output is the code generated from an item template. I have customized the testsettings file for my requirement and I should be able to add that to a Solution folder named "Solution Items".

    Thanks,


    Ajeeth Kumar.A, Cognizant

    Tuesday, September 11, 2012 6:19 AM
  • Hi Ajeeth,

    If we right click the solution and add a new item, we can get the item template in Solution folder and we can get the result like:

    Is this what you want?

    If I missed your purpose, please feel free to let me know.

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, September 12, 2012 8:28 AM
  • My aplologies I should have told my scenario clearly.

    I need to know how I can unfold an item template to a solution folder programatically using the VS DTE. The solutionFolder.AddFromTemplate() method is not working for me.

    Thanks,


    Ajeeth Kumar.A, Cognizant

    Wednesday, September 12, 2012 11:51 AM
  • Not working, what do you mean ? 

    It throws an exception ?

    - AddFromTemplate takes full path of the item template zip, which can be found using Solution2 GetTemplatePath (not sure about mathod name) with a patch like "Visual C#\Windows\..." as argument

    The item isn't placed into the right folder ?

    - Retrieve the new ProjectItem and add it to your specific folder using AddFromFile from folder projectitem

    Wednesday, September 12, 2012 1:55 PM
  • Yeah it throws exeption 'Item templates can be added only to Projects'. The solution folder is not of type Project. Any workarounds? I did manage to dig into the code of Test template's IWizard implementation using Refelector. However it seems to be very complex.

    Ajeeth Kumar.A, Cognizant

    Thursday, September 13, 2012 5:56 AM
  • This because you file template is a project item template.

    I suppose your item template belongs to specific type of project (like C# library), that why i can't be added to a solution folder.

    For exemple, when you try to add a new item to a solution folder using Visual Studio, you'll only see project items that are in General Category. All those files are not "templates", they can be find here : Microsoft Visual Studio 10.0 install dir\Common7\IDE\NewFileItems

    Only (in my case) testsettings uses a template.

    Could you please provide the vstemplate code of your item template, or try to adapt to remove project type dependency

    • Marked as answer by Ego Jiang Thursday, September 20, 2012 9:26 AM
    Thursday, September 13, 2012 7:47 AM