index > Visual Studio Guidance Automation Toolkit > Parameterising ProjectType in VS2005 templates

Parameterising ProjectType in VS2005 templates

Is it possible to parameterise the ProjectType node in studio 2005 template files?

The problem I have is like this, our development team write in both C# and VB and I want to write a guidance package to help speed up development in both code camps.

The classes within my package are generated using code (CodeDomProvider, etc) so I can squirt out class code in either language Ok. But I have hit a problem when it comes to solution & project files as they are templated and have the language set in the ProjectType element.

Do I need to write 2 packages with the majority of stuff exactly the same but different solution & project templates or am I missing a trick here?

Can I either:

  • parameterise the ProjectType element in the solution & the project templates
  • create the solution & project files using code
  • create the solution & projects without a ProjectType element and infer the language in some other way

Hopefully someone can offer some assistance here as I don't really want to have to duplicate the solution & project files if I don't have to :)

Thanks,
Sara

Sara_H

Hi Sara,

You definitely not need to write two almost identical packages for this.

Although you can use GAX to parameterise the .vstemplate and specify the ProjectType (by getting its value from a recipe argument for instance) I believe a better approach would be to have a different templates for each language (inside the same package), one for VB & and another one for C#; this means duplicate .proj and vstemplates files which may seem odd at first but is really an advantage once you start customizing the projects, as you will need to customize other settings besides ProjectType, like which msbuild targets to import for each project file, etc.

Does this help?

-Victor.

vga

Thanks for that idea Victor, I'm giving this a go right now on our main guidance package.

Sara

Sara_H

Great, let us know if you find any issues regarding this.

thanks,
-Victor.

vga

Hi Victor,

I've managed to set the guidance package to use different projects Ok by creating the relevant solutions files and sharing my code generating functionality. So I can now generate projects and code in C# or VB depending on which package was used (hurray!).

BUT ... my glee was short lived as I've hit a bit of an issue with taking this approach

The code generation files I'm using create a CodeCompileUnit using a CodeNamespace object as the base to build on. This works fine until your combine this with the fact that VB automatically appends any namespace defined in code files to any default namespace defined in the project! (And we have default namespaces defined) If I remove the namespace object I cannot create a CodeCompileUnit as it requires a CodeNamespace object in order to work properly.

Is there a way I can either tell the code DOM to not generate the namespace declaration code for VB or can I use parameterised T4 templates to achieve the code generation instead?

If I should be using T4 templates, can you explain how I can parameterise the template names? I appreciate that I will need different templates for C# and VB but I don't want to have duplicate all my receipes where the template names are hard coded. I ask as I have already looked at the TextTemplateAction object and it only accepts a template name as a string rather than an expression to evaluate - and I cannot inherit from this object and extend it as it is sealed.

Further help gratefully received
Sara

Sara_H
reply 5

You can use google to search for other answers

 

More Articles

• Project reference problem
• GAT Custom Directive Processor
• How should I deploy additional binaries?
• Will we see an updated GAT Toolkit soon?
• ProjectReference
• UIPAB
• Converting IDTWizard to GAT project and solution templates.
• VSTS - Web Test - FIND TEXT command
• Introduction to GAT
• How do you pass arguments from previous wizard pages
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• make wizard check in file after automate
• Problem with Specifying Command Bars
• Changes to the ProjectName from a Wizard
• Update guidance already installed
• How do you enable delay signing on a web
• June 2006 CTP and Hands On Lab
• Problem Loading Package
• How to use Generic List in T3
• DependentUpon
• Will we see an updated GAT Toolkit soon?
• Simulate DependentUpon with DTE class
• GAT/GAX for VS2005 RTM released!
• Error 1001: Item has already been added.
• How do I add an empty project folder?
• Minor bug in VszWizard.FindAddItem

Hot Articles

• Can't Drag Controls onto CustomWizPages
• Guidance Automation Extensions and Toolk
• How to Create Web Service Agent ?
• Project templates do not appear in VS 20
• Thanks for the tip
• Uninstalling Missing Packages
• GAT breaking changes
• Generic argument types
• Extending Designer Toolbox
• Error while unistalling Guidance Automat
• How do you add a using/reference to a t4
• Project reference problem
• new to GAT
• Debugging your packages.
• Reality Check?

Recommend Articles

• Added project reference not reflected
• How can you provide input to AddProjectD
• Type of Document objects retrieved from
• Multiple Project Creation Template
• Parameterising ProjectType in VS2005 tem
• Creating projects in a subdirectory
• GAT on Visual Studio Release Candidate
• Generic argument types
• Can't download GAT, GAX?
• TechEd Hands On Lab 2005 - Exercise 2 -
• Converting IDTWizard to GAT project and
• Synchronizing - GAT Package Changes
• How to Add Fixed Assets in GAT?
• Project References Guids?
• How to gather data without wizard