Can I create my own project template? 
Author Message
 Can I create my own project template?

For example, I always need to reference some assemblies in my project, and I
always need to using some namesapce in my project.
Can I create my own project template on New Project dialogbox?

Thanks a lot.

Clare Hsiao
Taipei,Taiwan



Wed, 06 Oct 2004 16:01:40 GMT  
 Can I create my own project template?
Hello Clare,

I have found a post about how to create a Project Template, which was
written by Andi. For your convenience, I have included it here:

Hi Folks,

I 've find out how you could add the missing project support back to the
standard IDE. The description follows allows YOU to add ANY KIND of project
templates to your IDE and work with them the way YOU like.....

1. The project templates / wizard support of the IDE is based on HTML forms,
JScript files and template code files which will be copied by the wizard and
adapted to your input settings. This is possible because the VS.NET IDE
provides an astonishing automation support so that you can access nearly all
objects and functionality it offers through scripts !!

2. The project settings / wizards ONLY differs in 2 ways - a) the output
type the compiler will generate (exe, winexe, dll) and b) the amount of code
and references already getting in into your project.
That is fully customizable. The output type can be changed by setting an
XML-attribute in your csproj-file called outputtype. It can further accessed
by script (objProject.OutputType = xxxx) so it should be easy to change that
thing. The amount of code and references will be adjusted by using the
scripts and code templates support.

So what should you do to generate an own project template ??

First take a look into your installation directory (normally Program
Files\Microsoft VisualStudio.NET). You will notice that it contains a
sub-directory called VC#. That directory contains other sub-directories like
CSharpContextItems, CSharpProjectItems, CSharpProjects and last but not
least VC#Wizards !
Take a look into the VC#Wizards directory. What you find here is one
sub-directory per wizard and some generally .csproj files. Now take a look
at the CSharpEXEWiz - which is the wizard for generating a console
application and will be based for all further project template generation.
You will notice 2 sub-directories called scripts and templates. Beneath them
you find a directory resembling your language code (1033 = UsEn) containing
either a default.js (the script) or some template files (file1.cs, app.ico
etc.).

The script file has the logic what to do with those files, what kind of
project will be generated and what references should be setted up for you.
It's quite simple and easy to understand (btw : the functions to add the
references to your project has been swapped out to a common script lying
directly below VC#Wizards\<language code>.

The template files should be easy to understand too. Please take care that
every file you wish to be copied to your destination directory by the wizard
must have been stated in the templates.ini file.

Now, if you have generated your own project wizard (or what ever wizard you
like... others are not described in this mail as the way they will be added
to the IDE is not fully clear at this moment - any suggestions will be
welcomed) you have to add the support to the IDE.

Therefore look into the VC#\CSharpProjects directory. Here you find a .vsz
file for each project wizard. Simply take one as template and copy it to the
same location giving it meaningful name. Look into the file and you will
notice that there is an entry which states the directory for the wizard
files (scripts and templates). Please adapt that to the name of the
directory your own wizard lives. Also you could state here if the wizard
uses a GUI (means a HTML form for getting user input). This could also not
described yet as it's not fully understand by me (please mail ANY hints).

If you start your IDE now you will notice your new project wizard appears
with an standard icon on the project items dialog box. Also the name
corresponds to the file name of the .vsz file and the description is
missing.

To change that behavior just take a look into the .vsdir file lying in your
VC#\CSharpProjects directory. You will notice that in this file every
standard wizard has a configuration line with some cryptic keys. After some
searching done by me it's meaning could be described now :

e.g.
CSharpEXE.vsz|{FAE04EC1-301F-11d3-BF4B-00C04F79EFBC}|#2318|10|#2319|{FAE04EC
1-301F-11d3-BF4B-00C04F79EFBC}|4554| |WindowsApplication

The entries have been separated by "|" :

1. the name of the wizard file in the VC#\CSharpProjects directory
2. the GUID for the component containing the language dependent text and
description (for C# Projects this will be the <csprojui.dll> situated in
<VS.NET-DIR>\VC7\vcpackages\<language-code>). You could open that file with
the IDE (has build in resource file support) and look into the string
resource to get the description and text you like
3. this text states the name of the item shown in the list box (either a
reference to a string resource or the text itself)
4. the sorting criteria - to specify the arragement of the items
5. the description of the item (shown in the lower left status line) -
either a reference to a string resource or the description itself (e.g.
Creates an empty project)
6. the GUID for the component containing the icon for this project type (for
c# projects this is the file <csproj.dll>.  You could open that file with
the IDE (has build in resource file support) and look into the string
resource to get the the numerical identifier of the icon you want to use.
7. describes flags for special behavior of the IDE - e.g. if stated to 1
this project will be NOT LOCAL but maybe a WEBPROJECT (differs in the way
this project type will be generated)
8. a suggestion of the project name
9. (at web projects only ==  web)

So you can add your own wizard files here and give them a meaningful text
and icon.

So guys to give YOU ALL the opportunity to work with the std. IDE having
support for each .NET project type I have included a ZIP file containing the
project wizard generated on my machine (this ZIP contains every missing
project wizard as all those wizards stated in the MSDN and missing in the
standard version has been created and successfully tried by myself) !!

The next step I will try to complete is to get the ability of changing EVERY
project's output type back into the IDE - as this property dialog has been
removed in the standard IDE (normally it's situated in
project-options\general\output type).

I haven't found a way to do that now besides of the scripting support of the
IDE. But what I wanna have is some dialog where I could select the output
type from a drop-down-box. If somebody is getting behind a mechanism how to
add GUI elements to macros, how to add user defined property-entries to the
option dialog or how to work with the HTML-GUI-wizards..... PLEASE SEND ME A
HINT.....

For all of the others out there working with VS.NET or the .NET
Framework..... HAVE FUN and ENJOY THE POSSIBILITIES :-)

Best regards,

Lion Shi, MCSE, MCSD
Microsoft Support Engineer

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.  2001 Microsoft Corporation. All rights
reserved.
--------------------

    Subject: Can I create my own project template?
    Date: Sat, 20 Apr 2002 16:01:40 +0800
    Lines: 10
    X-Priority: 3
    X-MSMail-Priority: Normal
    X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
    X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000

    Newsgroups: microsoft.public.dotnet.languages.csharp
    NNTP-Posting-Host: 61-224-152-128.hinet-ip.hinet.net 61.224.152.128
    Path: cpmsftngxa07!cpmsftngxa09!tkmsftngp01!tkmsftngp02
    Xref: cpmsftngxa07 microsoft.public.dotnet.languages.csharp:55519
    X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

    For example, I always need to reference some assemblies in my project,
and I
    always need to using some namesapce in my project.
    Can I create my own project template on New Project dialogbox?

    Thanks a lot.

    Clare Hsiao
    Taipei,Taiwan



Sat, 09 Oct 2004 15:25:40 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Creating custom project template

2. C problem involving creating creating your own .LIB file

3. Creating from Templates not in Templates folder in Excel 2000

4. .NET project locking/loading DLL created by other .NET project

5. .NET project locking/loading DLL created by other .NET project

6. own menu for new document/view template

7. Create a new Project from a Existing Project?

8. I want build a my own error code DLL for all my projects

9. New Project ->own code

10. include my own font in a MFC project

11. Determining what canned preprocessor symbols are available

12. Beginner [Q] Using Canned File Open/Save dialog

 

 
Powered by phpBB® Forum Software