Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > How to get RecipeArgument Value
 

How to get RecipeArgument Value

Hello Everybody,

I am using Software factory toolkit

I create a new Argument named Fameworkat CreateSolution.Xml file

My CreateSolution.Xml is as under:

**************CreateSolution.xml*******************************************

<Arguments>
<Argument Name="SolutionName">
<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="Framework" Type="System.String"/>

</Arguments>

<GatheringServiceData>
<Wizard xmlns="http://schemas.microsoft.com/pag/gax-wizards" SchemaVersion="1.0">
<Pages>
<Page>
<Title>New Solution</Title>
<Fields>

<Field ValueName="Framework" Label=" Framework Location"/>

</Page>

</Pages>

</Wizard>
</GatheringServiceData>

<Actions>
<Action Type="Test.Actions.CreateDirectory,Test" Name="CreateDir">
<Input Name="Framework" RecipeArgument="Framework" >
</Input>
</Action>

********************************************************************************************

I want to get value of Argument Framework at my CreateDirectory.cs(Action file).

I do at CreateDirectory.cs

************************CreateDirectory.cs************************************************

public class CreateDirectory: ActionBase
{
private string framework ;
[Microsoft.Practices.WizardFramework.CustomWizardPage.RecipeArgument]
public string Framework
{

set
{
framework = value;

}


}

protected override void OnExecute()
{}

protected override void OnUndo()

{}

************************************************************************************

Note:framework is a private variable declare at Createdirectory.cs file while

Framework is the Argument declare at CreateSolution.xml file.

In Place of [Microsoft.Practices.WizardFramework.CustomWizardPage.RecipeArgument]
I also Try [Input]

But same problem is occur with both

************************************************************************************

Build and register is successfull but when I start my new above created package

I get the following error

*****************************************************************************************

Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe CreateSolution. Error was: Action CreateDir failed to execute:
An exception occurred during the binding of reference or execution of recipe CreateSolution. Error was: Action CreateDir failed to execute:
Property Framework does not exist on type Test.Actions.CreateDirectory..
You can remove the reference to this recipe through the Guidance Package Manager..
You can remove the reference to this recipe through the Guidance Package Manager. ---> Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe CreateSolution. Error was: Action CreateDir failed to execute:
Property Framework does not exist on type Test.Actions.CreateDirectory..
You can remove the reference to this recipe through the Guidance Package Manager.
at Microsoft.Practices.RecipeFramework.Recipe.SetupInputs(IAction action, Action config, IDictionary actions, IDictionaryService arguments)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName, Dictionary`2 inputValues)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionExecutionService.Execute(String actionName)
at Microsoft.Practices.RecipeFramework.Recipe.Microsoft.Practices.RecipeFramework.Services.IActionCoordinationService.Run(Dictionary`2 declaredActions, XmlElement coordinationData)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)

--- End of inner exception stack trace ---
at Microsoft.Practices.RecipeFramework.Recipe.UndoExecutedActionsAndRethrow(Exception ex)
at Microsoft.Practices.RecipeFramework.Recipe.ExecuteActions(IDictionaryService readOnlyArguments, IDictionaryService arguments, ITypeResolutionService resolution)
at Microsoft.Practices.RecipeFramework.Recipe.Execute(Boolean allowSuspend)
at Microsoft.Practices.RecipeFramework.GuidancePackage.Execute(String recipe, IAssetReference reference, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.GuidancePackage.ExecuteFromTemplate(String recipe, IDictionary arguments)
at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate.ExecuteRecipe(Boolean executeActions)
at Microsoft.Practices.RecipeFramework.VisualStudio.Templates.UnfoldTemplate.RunFinished()
**************************************************************************************

Please Help me.

Thanks

Monesh  Monday, June 11, 2007 12:07 PM

Hello Everyone

I get the solution:

protected override void OnExecute()
{

IDictionaryService dictionary = (IDictionaryService)GetService(typeof(IDictionaryService));
object value = dictionary.GetValue("Framework");
String frameworkLocation = (String)value;

}

That how,I can get value of Argument.

Monesh  Tuesday, June 12, 2007 9:01 AM
Hi Monesh,

If you're using the Clarius Software Factories Toolkit (as you mention) you can save some code by just doing:

GetArgument("FSE4Framework")

All actions in SFT inherit from ActionBase and thus have some helper methods like the just mentioned one. Others are:

VisualStudio property -- this will get you a reference to DTE.
GetPackageBasePath() method -- this will get you the base path where you guidance package is running.
GetSolutionBasePath() method -- this will get you the base path of the solution currently opened.

HTH,
-Victor.
vga  Tuesday, June 12, 2007 4:52 PM

Hello Everyone

I get the solution:

protected override void OnExecute()
{

IDictionaryService dictionary = (IDictionaryService)GetService(typeof(IDictionaryService));
object value = dictionary.GetValue("Framework");
String frameworkLocation = (String)value;

}

That how,I can get value of Argument.

Monesh  Tuesday, June 12, 2007 9:01 AM
Hi Monesh,

If you're using the Clarius Software Factories Toolkit (as you mention) you can save some code by just doing:

GetArgument("FSE4Framework")

All actions in SFT inherit from ActionBase and thus have some helper methods like the just mentioned one. Others are:

VisualStudio property -- this will get you a reference to DTE.
GetPackageBasePath() method -- this will get you the base path where you guidance package is running.
GetSolutionBasePath() method -- this will get you the base path of the solution currently opened.

HTH,
-Victor.
vga  Tuesday, June 12, 2007 4:52 PM

You can use google to search for other answers

Custom Search

More Threads

• Trying to add a new class to the References folder...
• Can not install Web Client Software Factory Templates
• Problems with GAT and VS 2008
• How can you provide input to AddProjectDependencyAction without a wizard?
• Chaining recipes
• Best Practices for GP?
• Templates with Unicode names
• Extending Designer Toolbox
• Project templates do not appear in VS 2005 Pro after installing GAX and GAT?
• How does the .vstemplate run?