Andrew Horth

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 is a 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



Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Callum

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





Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Andrew Horth

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





Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Callum

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





Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Andrew Horth

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 it all on there...

Regards,

Andrew





Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Callum

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





Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Callum

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





Re: Visual Studio Guidance Automation Toolkit ProjectTemplateLink does not support substitution parameters (as used by GAT & SFT)

Andrew Horth

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