locked
Do I have to mark all instances of Project Template parameters, or does once suffice? RRS feed

  • Question

  • Normally, there's much more activity on stackOverflow, but this time no go, so I'm posting here re: Visual Studio Project Templates:

    I'm creating a VS 2010 Project Template.

    For a given value that needs to be globally replaced when using the Project Template, do I need to tag all of the instances of that value, or just one. IOW, do I need to do this:

    namespace $Platypus$ {
        public partial class $Form1$ : Form {

            private static readonly ILog log = LogManager.GetLogger(typeof($Form1$));

            public $Form1$() {
                InitializeComponent();
            }
        }
    }
    ...or this:

    namespace $Platypus$ { // this is the only Platypus to which I prepend and append a dollar sign
        public partial class $Form1$ : Form { // this is the only Form1 to which I prepend and append a dollar sign

            private static readonly ILog log = LogManager.GetLogger(typeof(Form1));

            public Form1() {
                InitializeComponent();
            }
        }
    }

    Monday, July 30, 2012 3:39 PM

Answers

  • Hi B.Clay,

    I think you use the wrong template parameters. And it will not work.

    You created a project template. When you create a new project, $Form1$ will not be replaced.

    However if we create a project item template and define your .cs file like:

    namespace $rootnamespace$ {
        public partial class $safeitemname$ : Form {

            private static readonly ILog log = LogManager.GetLogger(typeof($safeitemname$));

            public $safeitemname$() {
                InitializeComponent();
            }
        }
    }

    we can create a project item succefully.

    You can find more Template Parameters from:

    http://msdn.microsoft.com/en-us/library/eehb4faa(v=vs.100).aspx

    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

    • Proposed as answer by Ego Jiang Tuesday, July 31, 2012 6:22 AM
    • Marked as answer by B. Clay Shannon Tuesday, July 31, 2012 4:45 PM
    Tuesday, July 31, 2012 6:20 AM

All replies

  • Hi B.Clay,

    I think you use the wrong template parameters. And it will not work.

    You created a project template. When you create a new project, $Form1$ will not be replaced.

    However if we create a project item template and define your .cs file like:

    namespace $rootnamespace$ {
        public partial class $safeitemname$ : Form {

            private static readonly ILog log = LogManager.GetLogger(typeof($safeitemname$));

            public $safeitemname$() {
                InitializeComponent();
            }
        }
    }

    we can create a project item succefully.

    You can find more Template Parameters from:

    http://msdn.microsoft.com/en-us/library/eehb4faa(v=vs.100).aspx

    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

    • Proposed as answer by Ego Jiang Tuesday, July 31, 2012 6:22 AM
    • Marked as answer by B. Clay Shannon Tuesday, July 31, 2012 4:45 PM
    Tuesday, July 31, 2012 6:20 AM
  • Thanks, Ego; hopefully you don't have a big ego now, but you were the only cat who was able to give me any kind of answer on this in two days, both here and on stackOverflow.

    Apparently Project Templates are a seldom-used and/or little-understood feature. They could be a lot more user-friendly, and I can imagine a lot of people making good use of them if they were: many organizations create a bevy of apps with common functionality (a lot of "busy work" at the beginning adding certain references and components and a certain "look and feel" etc.). FWIW.

    Tuesday, July 31, 2012 4:44 PM