Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Can't get Recipe arguments into template - using UnfoldTemplateAction
 

Can't get Recipe arguments into template - using UnfoldTemplateAction

Hi all,

I'm trying to write a recipe which unfolds two different vstemplates into an existing solution. The templates unfold correctly, however I'm unable to substitute arguments from the recipe which is calling the UnfoldTemplateAction.

For example:

  • I have a package, whichhas one recipe in it which will unfold two projects into an already created solution.
  • In the Templates\Solutions\Project\Silo\ folder are the project files and the .vbprog files and the controlling .vstemplatefile.
  • I run the recipe and set the SiloName argument to "TestSilo".
  • In the .vstemplate file I have a line

    <ProjectItem ReplaceParameters="true" TargetFileName="$SiloName$.Files.wxs">Files.wxs</ProjectItem>

    which is intended to use the recipe argument substitute.
  • In the Files.wxs file there is a line

    src="$(sys.SOURCEFILEDIR)..\$SiloName$\obj\$(var.Config)\"

    which is intended to use the recipe argument to substitute.

However, neither arguement is replaced when the recipe runs and unfolds the templates. The File.wxs file is created in my project as

$SiloName$.Files.wxs

not

TestSilo.Files.wxs

and in that file, the src line is generated as

src="$(sys.SOURCEFILEDIR)..\$SiloName$\obj\$(var.Config)\"

not

src="$(sys.SOURCEFILEDIR)..\TestSilo\obj\$(var.Config)\"

I have packageswhich do this already, however the arguments are in a recipe which is called by the vstemplate (see below), so the recipe is called by the solution vstemplate - which is the opposite way round to how I amcalling them now - the recipe unfolds the vstemplate, not the template calling the recipe when started from "New Project...."

<WizardData>

<Template xmlns="http://schemas.microsoft.com/pag/gax-template"

SchemaVersion="1.0"

Recipe="CreateSolution">

<References/>

</Template>

</WizardData>

But this is not applicable for me here, as I am trying to unfold two project templates in a solution which is already created.

Can anyone help, so are you not able to use recipe arguements in vstemplates called by UnfoldTemplateAction???

Thanks

Alex Stevens  Thursday, May 31, 2007 2:46 PM

No, sorry I didn't see that you're using the UnfoldTemplateAction, the thing there is that if you want to replace the parameters you should use a recipe associated with the WizardData extension like this:

<WizardExtension>

<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.2.0.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="MyRecipe"/>

</WizardData>

unfortunately it works only with template references because you can't call a recipe from an another recipe.

Jose Escrich  Monday, June 04, 2007 4:53 AM

Did you set the GAX wizard extension in the that templates?

like this:

<WizardExtension>

<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>

<FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</FullClassName>

</WizardExtension>

Jose Escrich  Thursday, May 31, 2007 5:32 PM

Jose, thank you for the reply - however I already have that set in my template file.

I've reproduced below the vstemplate file and the recipe I'm using. Surely you are able to include recipe arguments in vstemplates and files marked ReplaceParameters="true" when using the UnfoldTemplateAction?????

***** vstemplate file *****

Code Snippet

<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">

<TemplateData>

<Name>Create Silo Setup</< FONT>Name>

<Description>Creates a setup project for a given silo.</< FONT>Description>

<ProjectType>VisualBasic</< FONT>ProjectType>

<ProjectSubType></< FONT>ProjectSubType>

<SortOrder>1000</< FONT>SortOrder>

<CreateNewFolder>true</< FONT>CreateNewFolder>

<DefaultName>Silo.Setup</< FONT>DefaultName>

<ProvideDefaultName>true</< FONT>ProvideDefaultName>

<LocationField>Enabled</< FONT>LocationField>

<EnableLocationBrowseButton>true</< FONT>EnableLocationBrowseButton>

<Icon>__TemplateIcon.ico</< FONT>Icon>

</< FONT>TemplateData>

<TemplateContent>

<Project File="Setup.csproj" ReplaceParameters="true">

<ProjectItem ReplaceParameters="true" TargetFileName="Files.wxs">Files.wxs</< FONT>ProjectItem>

<ProjectItem ReplaceParameters="true">Product.wxs</< FONT>ProjectItem>

</< FONT>Project>

</< FONT>TemplateContent>

<WizardExtension>

<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</< FONT>Assembly>

<FullClassName>Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate</< FONT>FullClassName>

</< FONT>WizardExtension>

<WizardData>

<Template xmlns="http://schemas.microsoft.com/pag/gax-template" SchemaVersion="1.0" />

</< FONT>WizardData>

</< FONT>VSTemplate>

***** Recipe file *****

Code Snippet

<?xml version="1.0" encoding="utf-8" ?>

<Recipe

Name="CreateNewSilo"

xmlns="http://schemas.microsoft.com/pag/gax-core"

xmlns:xi="http://www.w3.org/2001/XInclude"

Bound="false">

<xi:include href="..\TypeAlias.xml" xmlns:xi="http://www.w3.org/2001/XInclude" />

<!--Some descriptive information to be displayed for our recipe.-->

<Caption>Create a new UI Silo</Caption>

<Description>Creates a new UI silo project and the associated setup project.</Description>

<!--This details the locations within the solution structure that the recipe will be displayed.-->

<HostData>

<Icon ID="1046"/>

<CommandBar Name="Solution Folder" />

<CommandBar Name="Solution" />

</HostData>

<!--These are the required arguments for our recipe.-->

<Arguments>

<Argument Name="SiloName" Type="System.String" Required="true" />

<Argument Name="SiloSetupName" Type="System.String" Required="true">

<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(SiloName).Setup">

<MonitorArgument Name="SiloName"/>

</ValueProvider>

</Argument>

<Argument Name="CreateSetupProject" Type="System.Boolean" Required="true" />

<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="SolutionPath">

<ValueProvider Type="SolutionPathProvider" />

</Argument>

<Argument Name="NewSiloProjectFolder">

<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(SolutionPath)\Private\$(SiloName)\">

<MonitorArgument Name="SolutionPath"/>

<MonitorArgument Name="SiloName"/>

</ValueProvider>

</Argument>

<Argument Name="NewSiloSetupProjectFolder">

<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(SolutionPath)\Private\$(SiloSetupName)\">

<MonitorArgument Name="SolutionPath"/>

<MonitorArgument Name="SiloSetupName"/>

</ValueProvider>

</Argument>

<Argument Name="ParentWebProject" Type="EnvDTE.Project, EnvDTE, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">

<Converter Type="ProjectWithResponsibilityConverter" />

</Argument>

<Argument Name="ParentNamespace" Type="System.String">

<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(ParentWebProject.Properties.Item('DefaultNamespace').Value.ToString())">

<MonitorArgument Name="ParentWebProject"/>

</ValueProvider>

</Argument>

<Argument Name="SiloNamespace" Type="System.String">

<ValueProvider Type="ExpressionEvaluatorValueProvider" Expression="$(ParentNamespace).$(SiloName)">

<MonitorArgument Name="ParentWebProject"/>

</ValueProvider>

</Argument>

</Arguments>

<!--This will collect the information from the UI.-->

<GatheringServiceData>

<Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">

<Pages>

<Page>

<Title>Silo Information</Title>

<LinkTitle>Provide the information required for a silo project.</LinkTitle>

<Help>You shouldn't need a lot of help!</Help>

<Fields>

<Field ValueName="SiloName" Label="Silo Name">

<Tooltip>The name of the silo to be created.</Tooltip>

</Field>

<Field ValueName="ParentWebProject" Label="Parent Web Project">

<Tooltip>The parent web project for this new silo.</Tooltip>

</Field>

<Field ValueName="CreateSetupProject" Label="Create Setup for Silo">

<Tooltip>Optionally create a setup project for the Silo</Tooltip>

</Field>

<Field ValueName="ParentNamespace" Label="Create Setup for Silo">

<Tooltip>Optionally create a setup project for the Silo</Tooltip>

</Field>

</Fields>

</Page>

</Pages>

</Wizard>

</GatheringServiceData>

<!--Will perform the actions required to fulfill the end result.-->

<Actions>

<!--Unfold the silo template-->

<Action Name="UnfoldSiloProjectTemplate"

Type="UnfoldTemplateAction"

Template="Solutions\Projects\Silo\Silo.vstemplate" >

<Input Name="Root" RecipeArgument="SolutionArgument" />

<Input Name="DestinationFolder" RecipeArgument="NewSiloProjectFolder" />

<Input Name="ItemName" RecipeArgument="SiloName" />

<Output Name="NewItem" />

</Action>

<!--Unfold the silo template-->

<Action Name="UnfoldSiloSetupProjectTemplate"

Type="UnfoldTemplateAction"

Template="Solutions\Projects\SiloSetup\SiloSetup.vstemplate" >

<Input Name="Root" RecipeArgument="SolutionArgument" />

<Input Name="DestinationFolder" RecipeArgument="NewSiloSetupProjectFolder" />

<Input Name="ItemName" RecipeArgument="SiloSetupName" />

<Output Name="NewItem" />

</Action>

</Actions>

</Recipe>

Alex Stevens  Friday, June 01, 2007 8:01 AM

No, sorry I didn't see that you're using the UnfoldTemplateAction, the thing there is that if you want to replace the parameters you should use a recipe associated with the WizardData extension like this:

<WizardExtension>

<Assembly>Microsoft.Practices.RecipeFramework.VisualStudio, Version=1.2.0.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="MyRecipe"/>

</WizardData>

unfortunately it works only with template references because you can't call a recipe from an another recipe.

Jose Escrich  Monday, June 04, 2007 4:53 AM

Is this still the case in the latest version of GAX/GAT/GEL?

I have this same issue and would like to know if this will ever be possible or if anyone has found a creative workaround.

thanks

Jeff

Jeff Paine  Tuesday, October 02, 2007 9:30 PM

Hi Jeff

You can find in my weblog a workaround for this issue, there you'll find an action which wraps the UnfoldTemplateAction and solve the problem.

http://weblogs.asp.net/jescrich/archive/2007/10/05/dealing-with-the-unfoldtemplateaction-and-parameter-replacement.aspx

hth

jose.

Jose Escrich  Friday, October 05, 2007 7:20 PM

You can use google to search for other answers

Custom Search

More Threads

• Exception while using the 'Add Event Publication' Recepie
• Not showing Added Item Template in Add New DailogBox
• Actions in Visual Studio 2005 Guidance Automation Toolkit (GAT) Very Slow
• Modify WCF Guidance Package
• CreateProjectAction Action will not work
• VSTS 2008 - installed GAX but GAT fails: C# Language is not installed
• Creating a non C# project template using GAT
• Windows Installer XML project for GAT Package?
• Parse referenced assemblies
• GuidanceAutomationExtensions.msi install error