Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > How to lauch a recipe programatically
 

How to lauch a recipe programatically


Hi,

does anyone know if it is possible to start a recipe programatically? Basic, my scenario is: the user has team explorer installed and i want to start a recipe when the user clicks a link in the "Links tab".

Is it possible?

Thanks in advance

BFC
BFC  Monday, September 15, 2008 9:39 AM
Hi BFC,

take a look to SFT (Software Factories Toolkit) @ http://www.softwarefactoriestoolkit.net/ , there you will find an ActionProgressCoordinator which is basically an action coordinator service, you can use that or you can learn how to launch a recipe programatically looking in that code.


Jose Escrich - weblogs.asp.net/jescrich
  • Marked As Answer byBFC Sunday, March 01, 2009 6:40 PM
  • Proposed As Answer byJose Escrich Wednesday, September 17, 2008 10:14 PM
  •  
Jose Escrich  Wednesday, September 17, 2008 10:14 PM
Hi there,

I have invoked from action of the one recipe programatically another recipe - 'TestRecipe'. I have implemented this into customized WSSF (Service Factory).

Here is the sample, Execute method of the action of the first recipe:


Reading content of the test recipe:
1FileStreamfs=
2newFileStream(@"..\TestRecipe.xml",FileMode.Open,FileAccess.Read);
3StreamReadersr=newStreamReader(fs);
4stringrecipeContent=sr.ReadToEnd();


Reading configuration (.xml) file of the executive Guidance Package and instancing new GP :
1 Microsoft.Practices.RecipeFramework.Configuration.GuidancePackagecurentConfig=
2 Microsoft.Practices.RecipeFramework.GuidancePackage.ReadConfiguration(@"..\CapabilityGuidancePackage.xml");
3
4 Microsoft.Practices.RecipeFramework.GuidancePackagecurentGPckg=
5 newMicrosoft.Practices.RecipeFramework.GuidancePackage(curentConfig);

Adding necassary servicers :
1 TypeResolutionService_trs=GetService(typeof(ITypeResolutionService))asTypeResolutionService;
2
3 curentGPckg.AddService(typeof(ITypeResolutionService),_trs);
4 curentGPckg.AddService(typeof(EnvDTE.DTE),this.Dte);

Executing test recipe:
1 Microsoft.Practices.Common.ExecutionResultexResult=curentGPckg.ExecuteFromTemplate("TestRecipe",null);


All together:
1 publicclassTestActionUnfold:ActionBase
2 {
3 publicoverridevoidExecute()
4 {
5 try
6 {
7 FileStreamfs=
8 newFileStream(@"..\TestRecipe.xml",FileMode.Open,FileAccess.Read);
9 StreamReadersr=newStreamReader(fs);
10 stringrecipeContent=sr.ReadToEnd();
11
12 Microsoft.Practices.RecipeFramework.Configuration.GuidancePackagecurentConfig=
13 Microsoft.Practices.RecipeFramework.GuidancePackage.ReadConfiguration(@"..\CapabilityGuidancePackage.xml");
14
15 Microsoft.Practices.RecipeFramework.GuidancePackagecurentGPckg=
16 newMicrosoft.Practices.RecipeFramework.GuidancePackage(curentConfig);
17
18 TypeResolutionService_trs=GetService(typeof(ITypeResolutionService))asTypeResolutionService;
19
20 curentGPckg.AddService(typeof(ITypeResolutionService),_trs);
21 curentGPckg.AddService(typeof(EnvDTE.DTE),this.Dte);
22
23
24 Microsoft.Practices.Common.ExecutionResultexResult=curentGPckg.ExecuteFromTemplate("TestRecipe",null);
25 }
26 catch(Exceptionex)
27 {
28 System.Diagnostics.Trace.WriteLine(ex);
29 throwex;
30
31 }
32 }
33 }


Also, it can be done with 'code recipe'.

You can instance Recipe class, something like this :

1Microsoft.Practices.RecipeFramework.Configuration.Reciperecipe=newMicrosoft.Practices.RecipeFramework.Configuration.Recipe();
2recipe.Name="TestRecipe";
3
4Microsoft.Practices.RecipeFramework.Configuration.Actionaction=newMicrosoft.Practices.RecipeFramework.Configuration.Action();
5action.Name="TestExecution";
6action.Type="SomeType,SomeAssembly";
7
8recipe.Actions.Action=newMicrosoft.Practices.RecipeFramework.Configuration.Action[]{action};

Hope this is useful, best regards,

Rastko
  • Proposed As Answer bycucciolo Friday, February 27, 2009 9:46 AM
  • Marked As Answer byBFC Sunday, March 01, 2009 6:42 PM
  •  
cucciolo  Friday, February 27, 2009 9:44 AM
Hi BFC,

take a look to SFT (Software Factories Toolkit) @ http://www.softwarefactoriestoolkit.net/ , there you will find an ActionProgressCoordinator which is basically an action coordinator service, you can use that or you can learn how to launch a recipe programatically looking in that code.


Jose Escrich - weblogs.asp.net/jescrich
  • Marked As Answer byBFC Sunday, March 01, 2009 6:40 PM
  • Proposed As Answer byJose Escrich Wednesday, September 17, 2008 10:14 PM
  •  
Jose Escrich  Wednesday, September 17, 2008 10:14 PM
Hi there,

I have invoked from action of the one recipe programatically another recipe - 'TestRecipe'. I have implemented this into customized WSSF (Service Factory).

Here is the sample, Execute method of the action of the first recipe:


Reading content of the test recipe:
1FileStreamfs=
2newFileStream(@"..\TestRecipe.xml",FileMode.Open,FileAccess.Read);
3StreamReadersr=newStreamReader(fs);
4stringrecipeContent=sr.ReadToEnd();


Reading configuration (.xml) file of the executive Guidance Package and instancing new GP :
1 Microsoft.Practices.RecipeFramework.Configuration.GuidancePackagecurentConfig=
2 Microsoft.Practices.RecipeFramework.GuidancePackage.ReadConfiguration(@"..\CapabilityGuidancePackage.xml");
3
4 Microsoft.Practices.RecipeFramework.GuidancePackagecurentGPckg=
5 newMicrosoft.Practices.RecipeFramework.GuidancePackage(curentConfig);

Adding necassary servicers :
1 TypeResolutionService_trs=GetService(typeof(ITypeResolutionService))asTypeResolutionService;
2
3 curentGPckg.AddService(typeof(ITypeResolutionService),_trs);
4 curentGPckg.AddService(typeof(EnvDTE.DTE),this.Dte);

Executing test recipe:
1 Microsoft.Practices.Common.ExecutionResultexResult=curentGPckg.ExecuteFromTemplate("TestRecipe",null);


All together:
1 publicclassTestActionUnfold:ActionBase
2 {
3 publicoverridevoidExecute()
4 {
5 try
6 {
7 FileStreamfs=
8 newFileStream(@"..\TestRecipe.xml",FileMode.Open,FileAccess.Read);
9 StreamReadersr=newStreamReader(fs);
10 stringrecipeContent=sr.ReadToEnd();
11
12 Microsoft.Practices.RecipeFramework.Configuration.GuidancePackagecurentConfig=
13 Microsoft.Practices.RecipeFramework.GuidancePackage.ReadConfiguration(@"..\CapabilityGuidancePackage.xml");
14
15 Microsoft.Practices.RecipeFramework.GuidancePackagecurentGPckg=
16 newMicrosoft.Practices.RecipeFramework.GuidancePackage(curentConfig);
17
18 TypeResolutionService_trs=GetService(typeof(ITypeResolutionService))asTypeResolutionService;
19
20 curentGPckg.AddService(typeof(ITypeResolutionService),_trs);
21 curentGPckg.AddService(typeof(EnvDTE.DTE),this.Dte);
22
23
24 Microsoft.Practices.Common.ExecutionResultexResult=curentGPckg.ExecuteFromTemplate("TestRecipe",null);
25 }
26 catch(Exceptionex)
27 {
28 System.Diagnostics.Trace.WriteLine(ex);
29 throwex;
30
31 }
32 }
33 }


Also, it can be done with 'code recipe'.

You can instance Recipe class, something like this :

1Microsoft.Practices.RecipeFramework.Configuration.Reciperecipe=newMicrosoft.Practices.RecipeFramework.Configuration.Recipe();
2recipe.Name="TestRecipe";
3
4Microsoft.Practices.RecipeFramework.Configuration.Actionaction=newMicrosoft.Practices.RecipeFramework.Configuration.Action();
5action.Name="TestExecution";
6action.Type="SomeType,SomeAssembly";
7
8recipe.Actions.Action=newMicrosoft.Practices.RecipeFramework.Configuration.Action[]{action};

Hope this is useful, best regards,

Rastko
  • Proposed As Answer bycucciolo Friday, February 27, 2009 9:46 AM
  • Marked As Answer byBFC Sunday, March 01, 2009 6:42 PM
  •  
cucciolo  Friday, February 27, 2009 9:44 AM

You can use google to search for other answers

Custom Search

More Threads

• Change location solution is unfolded to
• Parameterising ProjectType in VS2005 templates
• How to add a single file in a <ProjectCollection>..</ProjectCollection>.
• T4 template in Isolated Shell
• One Click
• How to add assemblies to solution-wide folder
• Can't run the Guidance Package
• What causes the project to be added under Guidance Packages when creating a new project?
• GAT and DSL
• Queued Recipe Execution