Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)
 

ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Both the GuidancePackageSolution.vstemplate file in GAT and SoftwareFactorySolutionCSharp.vstemplate / SoftwareFactorySolutionVB.vstemplate files in Clarius SFT use substitution parameters to specify the ProjectName attribute of ProjectTemplateLink elements - this does not appear to be supported by the visual studio template mechanism.

<TemplateContent>
<ProjectCollection>
<ProjectTemplateLink ProjectName="$PackageName$Installer">Projects\GuidancePackageInstaller\GuidancePackageInstaller.vstemplate</ProjectTemplateLink>
<ProjectTemplateLink ProjectName="$PackageName$">Projects\GuidancePackage\GuidancePackage.vstemplate</ProjectTemplateLink>
</ProjectCollection>
</TemplateContent>

This produces folders in windows explorer called (literally) $PackageName$ and $PackageName$Installer !

To help me learn about GAX etc., I have been writing my own Software Factory creator (i.e. a scaled down version of what SFT is trying to achieve) and have worked around this problem.

My solution .vstemplate file looks like the following:

<VSTemplate
Version="2.0"
Type="ProjectGroup"
xmlns="
http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>Software Factory (C#)</Name>
<Description>Creates a solution for developing a Software Factory in C#</Description>
<ProjectType>CSharp</ProjectType>
<SortOrder>90</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>SoftwareFactory</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<Icon>SoftwareFactorySolution.ico</Icon>
</TemplateData>
<TemplateContent>
<!-- Unfortunately the ProjectTemplateLink element does not support substitution parameters for the project name
so we will have to generate the package / installer / setup projects using a Recipe -->
<ProjectCollection/>
</TemplateContent>
<WizardExtension>
<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.0.60429.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</FullClassName>
</WizardExtension>
<WizardData>
<Template xmlns="
http://schemas.microsoft.com/pag/gax-template"
SchemaVersion="1.0"
Recipe="CreateSoftwareFactory">
<References>
</References>
</Template>
</WizardData>
</VSTemplate>

My CreateSoftwareFactory recipe contains actions which use the UnfoldTemplateAction action to manually unfold the project templates to the correct folders.
Here isa sample:

<Arguments>
<Argument Name="PackageName">
<Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.RegexMatchStringConverter, Microsoft.Practices.RecipeFramework.Library"
Expression="[a-zA-Z][a-zA-Z_0-9]*(\.[a-zA-Z][a-zA-Z_0-9]*)*"/>
<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(safeprojectname)"/>
</Argument>
<Argument Name="PackageCaption">
<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(safeprojectname)"/>
</Argument>
<Argument Name="PackageNamespace">
<Converter Type="Microsoft.Practices.RecipeFramework.Library.Converters.NamespaceStringConverter, Microsoft.Practices.RecipeFramework.Library"/>
</Argument>
<Argument Name="PackageDescription" />
<Argument Name="Author" Type="System.String">
<ValueProvider Type="DefaultAuthorValueProvider" />
</Argument>
<Argument Name="SolutionPath">
<ValueProvider Type="SolutionPathProvider" />
</Argument>
<Argument Name="SolutionArgument" Type="EnvDTE.Solution, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<Converter Type="SolutionConverter" />
<ValueProvider Type="ExpressionEvaluatorValueProvider"Expression="/" />
</Argument>
<Argument Name="ProjectFolder">
<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(SolutionPath)\$(PackageName)">
<MonitorArgument Name="PackageName"/>
</ValueProvider>
</Argument>
<Argument Name="InstallerProjectName">
<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(PackageName)Installer">
<MonitorArgument Name="PackageName"/>
</ValueProvider>
</Argument>
<Argument Name="InstallerProjectFolder">
<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(SolutionPath)\$(InstallerProjectName)">
<MonitorArgument Name="InstallerProjectName"/>
</ValueProvider>
</Argument>
</Arguments>
...

<Actions>
<!-- Trigger the unfolding of the Package / Installer .vstemplate files (which we didn't do
in the SoftwareFactorySolution.vstemplate file because we couldn't dynamically assign the project names there) -->
<Action Name="UnfoldPackageProjectTemplate"
Type="UnfoldTemplateAction"
Template="Solutions\Projects\SoftwareFactoryCSharp\SoftwareFactoryCSharp.vstemplate">
<Input Name="Root" RecipeArgument="SolutionArgument" />
<Input Name="DestinationFolder" RecipeArgument="ProjectFolder" />
<Input Name="ItemName" RecipeArgument="PackageName" />
<Output Name="NewItem" />
</Action>
<Action Name="UnfoldInstallerProjectTemplate"
Type="UnfoldTemplateAction"
Template="Solutions\Projects\SoftwareFactoryInstallerCSharp\SoftwareFactoryInstallerCSharp.vstemplate">
<Input Name="Root" RecipeArgument="SolutionArgument" />
<Input Name="DestinationFolder" RecipeArgument="InstallerProjectFolder" />
<Input Name="ItemName" RecipeArgument="InstallerProjectName" />
<Output Name="NewItem" />
</Action>

...

</Actions>

I hope this helps people who've had similar problems with solution templates ...

P.S. Perhaps the next releases of GAT / SFT could address this issue ?

Andrew Horth  Monday, March 26, 2007 12:23 PM

Hi Andrew,

I am trying to achieve something similar. However I'm not having any luck getting your sample to work. I'm playing around with it, the furthest I have got is to get the projects written to the file system, unfortunately there is an error adding them to the solution or saving the solution file or both.

Would it be possible for you to post a complete example?

Many thanks,

Callum

Callum  Thursday, April 19, 2007 2:00 PM

Hi Callum,

Sorry for the delayed response - I had some actual work to do !

Are you trying to make your own Software Factory 'creator' or do you just want an example recipe / set of templates etc.to create a solution with multiple projects?

Regards,

Andrew

Andrew Horth  Monday, May 14, 2007 11:55 AM

I'm trying to create my own Guidance package, morally the same as the "Web Services Software Factory" that has come out of the Microsoft Patterns and Practices people.

I want to control the folder structure on the file system when Projects are created/add.

If I have a project called "Namespace.ProjectName.csproj" I would like for the project file to be created in a folder structure such as "somepath\Namespace\ProjectName\Namespace.ProjectName.csproj" not "somepath\Namespace.ProjectName\Namespace.ProjectName.csproj" (notice the hierarchical folder structure).

Your sample seems to do that but as described I did not have much joy getting it to work for some reason, I think I may have missed something as Im trying to reverse engineer it from your snippets.

Thanks,

Callum

Callum  Monday, May 14, 2007 12:14 PM

Callum,

I've managed to knock up a guidance package which does what you want, however it is a nightmare trying to cut & paste everything into a single post !

I'll try and set up a blog somewhere over the weekend and put itall on there...

Regards,

Andrew

Andrew Horth  Friday, May 18, 2007 1:00 PM

Thanks. Very much appreciated.

I've temporarily made my e-mail address visible on my profile (remove the ".donotspam" suffix) if it is more convinient for you to send a zip file.

Thanks again.

Callum

Callum  Friday, May 18, 2007 7:58 PM

Hi Andrew,

Sorry to hassle you, I was wondering if you'd managed to put that example up somewhere? I'm still having problems myself and it would help me if I can cobble something together for next week.

My e-mail address is on my profile (click on my name on the left) if its easier for you to send me the zip file.

Thanks,

Callum

Callum  Tuesday, May 22, 2007 9:03 PM

Hi Callum,

I sent you the zipped guidance package source code.

If you didn't receive it then I have also posted the mother of all blogs (!)here http://hortha.spaces.live.com/blog/which contains all the source...

Regards

Andrew

Andrew Horth  Tuesday, May 29, 2007 8:57 PM

You can use google to search for other answers

Custom Search

More Threads

• How do I uninstall GAX manually from a Vista64bit os
• GuidanceAutomationExtensions.msi install error
• Help me decide: how to generate my Data Access Layer ( please :)
• Is GAT/GAX compatible with non-English versions of Visual Studio 2005 ?
• Not able to install on vista x64
• Guidance automation extensions exception
• Adding an Item to a solution (as opposed to a project)
• Guidance Package Build
• Beta 2 Class Wizard does not work
• Creating a non C# project template using GAT