Creating Project and Item templates with folders RRS feed

  • Question

  • Hi

    I am trying to create Project and Item Templates using Visual Studio 2010. I am able to create standard project template without any issue. Now I want to the following:

    1. Here where I work, we have one big project and under that project we have folder for each application. Each folder have subfolders and c# files. How can I do the following? 

    On project level I add an Item template, that adds the folder, subfolders and then the C# files? Basically, need to create folders first before adding the items in it (I don't want every one to add folders manually). Is this possible with Item Templates?

    2. I have create a project template, In my items (C# files) I have used parameters 

    namespace $rootnamespace$

    also, the .vstemplate file has ReplaceParameters set to True. But, the project template never compiles due to '$' in '$rootnamespace$'. Secondly, if exported like that, the parameters are never replaced by actual namespace. What am I missing?

    Friday, January 4, 2013 4:45 PM

All replies

  • Hi,

    First question, we can add the folder label in the template file like:

    <Folder Name="Properties" TargetFolderName="Properties">
        <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
       <Folder Name="UnitTests" TargetFolderName="UnitTests">
        <ProjectItem ReplaceParameters="true" TargetFileName="UnitTest1.cs">UnitTest1.cs</ProjectItem>

    Second question, as I know, parameter $rootnamespace$ applies only to item templates. Please change it to safeprojectname and try again.

    More information about Template Parameters you can refer to:


    Best regards, 

    Ego [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 7, 2013 8:37 AM
  • Thanks Ego.

    <Folder> tag is part of Project Template and not for Item Template. Right? In that case, I can't achieve, creating folder when I add an Item?

    For the second question, you were right and I was able to resolve the issue.

    Any idea how can I add custom assembly reference to the item template that has no strong name. I wan to reference the assembly from bin folder of my local project. 

    When I add a reference to my assembly like this:

    <Reference>        <Assembly>MyWebUtils, Version=8.3.842.0, Culture=neutral, PublicKeyToken=</Assembly></Reference>

    I get error when I use this template that "I can't add the assembly xyz to the project".

    • Edited by srireds Wednesday, January 9, 2013 8:05 PM
    Wednesday, January 9, 2013 5:11 PM