Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > CreateProjectAction Action will not work
 

CreateProjectAction Action will not work

Hi

I am working on a software factory to create a solution and some projects.

the projects have to be saved in specific locations based on user input.

I have the user input and now am trying to use the "CreateProjectAction" action. But i can't get it to work. I if use the "

<ProjectTemplateLink ProjectName="$ProjectName$">Projects\BizTalkApplication.vstemplate</ProjectTemplateLink>

" in the solution template it works fine, but the CreateProjectAction will not work.

the error code is:

=================================

Microsoft.Practices.RecipeFramework.ActionExecutionException: An exception occurred during the binding of reference or execution of recipe CreateISSolution. Error was: Action CreateProject failed to execute:

Kan niet vinden. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)).

You can remove the reference to this recipe through the Guidance Package Manager. ---> System.Runtime.InteropServices.COMException (0x80030002): Kan niet vinden. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND))

at EnvDTE.SolutionClass.AddFromTemplate(String FileName, String Destination, String ProjectName, Boolean Exclusive)

at Microsoft.Practices.RecipeFramework.Library.Actions.CreateProjectAction.Execute()

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()

=================================

so a file is not found, but which file?

Thanks for any input

Of is there another way to create projects on a specific folder location?

Thanks

Kees

Kees Wouters  Sunday, February 17, 2008 9:46 PM

The CreateProjectAction still does not work for me.

I have tried all kinds of methods to call the CreateProjectAction but with no success. So I am trying to add projects to my solution on another way.

One thing I found out is that Visual Studio 2005 works with a different way of dealing with templates. In VS2005 the templates have to be included in a zip file.

First I worked with code like this, to add two projects to the solution

Code Snippet

EnvDTE.DTE dte = this.GetService<EnvDTE.DTE>(true);

Solution2 soln = (Solution2)dte.Solution;

string btsRISPrjTemplatePath;

string btsSISPrjTemplatePath;

btsRISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

btsSISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

soln.AddFromTemplate(btsRISPrjTemplatePath, _RISProjectFolder, _RISProjectName, false);

soln.AddFromTemplate(btsSISPrjTemplatePath, _SISProjectFolder, _SISProjectName, false);

But i received the message: "Cannot add the item because the item to add it to is not a solution folder or the solution.. "

I am now adding the projects to my solution like this:

Code Snippet

EnvDTE.DTE dte = this.GetService<EnvDTE.DTE>(true);

Solution2 soln = (Solution2)dte.Solution;

string btsRISPrjTemplatePath;

string btsSISPrjTemplatePath;

btsRISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

btsSISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

Project prj;

SolutionFolder SF;

prj = soln.AddSolutionFolder("RIS");

SF = (SolutionFolder)prj.Object;

SF.AddFromTemplate(btsRISPrjTemplatePath, _RISProjectFolder, _RISProjectName);

prj = soln.AddSolutionFolder("SIS");

SF = (SolutionFolder)prj.Object;

SF.AddFromTemplate(btsRISPrjTemplatePath, _SISProjectFolder, _SISProjectName);

Using a solution folder.

This works for me now, as workaround for not getting the CreatProjectAction to work.

Now up to my next challenge; add orchestrations, maps and schemas to the projects!

Kees Wouters

Kees Wouters  Thursday, February 21, 2008 12:58 AM

Hi Kees,

You might want to have a look at the source code of Service Factory. This factory does excactly the same and it easy to copy the recipes needed for that into your own factory. I suggest (for now) to have a look at the Service Factory for VS 2005 because the VS 2008 version doesn't contain source code (at this moment) and has some issues installation issues with the latest version of GAX.

Hope this helps

Edward

Edward Bakker  Monday, February 18, 2008 10:34 AM

Hi Edward

thank you for your reply. I have looked at the Service factory example but it does not seem to give the example I need.

I want to create a solution and some projects which should be saved in another folder which is not a subfolder of the solution folder.

For example:

C:\Solutions\solution-a\solution.sln

C:\Projects\Project-a\project-a.brproj

C:\Projects\Project-b\project-b.brproj

so a solution folder with the project items nested in it will not work in this cast.

I would think the CreateProjectAction is able to do the trick, but I think I am overlooking something.

The action in my recipe is:

<Action Name="CreateProjectAction" Type="Microsoft.Practices.RecipeFramework.Library.Actions.CreateProjectAction, Microsoft.Practices.RecipeFramework.Library">

<Input Name="ProjectName" RecipeArgument="RISname"/>

<Input Name="Template" RecipeArgument="BizTalkTemplateProject"/>

<Input Name ="ProjectFolder" RecipeArgument="RISProjectFolder"/>

</Action>

I think the ProjectName can be a name fot the project

I thinkTemplate should be a relative path to the project template, starting at the Templates folder in the Visual Studio Templates folder.

I think the ProjectFolder should be a path to a folder.

In my test project:

the ProjectName is SAPS

the Template is \Projects\BizTalkApplication\BizTalkApplication.vstemplate

the ProjectFolder is C:\Projects\RIS\Interface\SAPS

Executing this example will give a STG_E_FILENOTFOUND error.

What am I missing....

thanks in advance.

Kees

Kees Wouters  Monday, February 18, 2008 9:42 PM

The CreateProjectAction still does not work for me.

I have tried all kinds of methods to call the CreateProjectAction but with no success. So I am trying to add projects to my solution on another way.

One thing I found out is that Visual Studio 2005 works with a different way of dealing with templates. In VS2005 the templates have to be included in a zip file.

First I worked with code like this, to add two projects to the solution

Code Snippet

EnvDTE.DTE dte = this.GetService<EnvDTE.DTE>(true);

Solution2 soln = (Solution2)dte.Solution;

string btsRISPrjTemplatePath;

string btsSISPrjTemplatePath;

btsRISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

btsSISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

soln.AddFromTemplate(btsRISPrjTemplatePath, _RISProjectFolder, _RISProjectName, false);

soln.AddFromTemplate(btsSISPrjTemplatePath, _SISProjectFolder, _SISProjectName, false);

But i received the message: "Cannot add the item because the item to add it to is not a solution folder or the solution.. "

I am now adding the projects to my solution like this:

Code Snippet

EnvDTE.DTE dte = this.GetService<EnvDTE.DTE>(true);

Solution2 soln = (Solution2)dte.Solution;

string btsRISPrjTemplatePath;

string btsSISPrjTemplatePath;

btsRISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

btsSISPrjTemplatePath = soln.GetProjectTemplate("Logica.EUT.ESB.BizTalkTemplate.zip", "CSharp");

Project prj;

SolutionFolder SF;

prj = soln.AddSolutionFolder("RIS");

SF = (SolutionFolder)prj.Object;

SF.AddFromTemplate(btsRISPrjTemplatePath, _RISProjectFolder, _RISProjectName);

prj = soln.AddSolutionFolder("SIS");

SF = (SolutionFolder)prj.Object;

SF.AddFromTemplate(btsRISPrjTemplatePath, _SISProjectFolder, _SISProjectName);

Using a solution folder.

This works for me now, as workaround for not getting the CreatProjectAction to work.

Now up to my next challenge; add orchestrations, maps and schemas to the projects!

Kees Wouters

Kees Wouters  Thursday, February 21, 2008 12:58 AM

Hey Kees,

I am also facing same problem and trying to implement the workaround as you did. Could you please help me understand following point.

1) How the zip file for template would be created? Will guidance package installer will do it or I will have to manually create it.

2) Where do place this file?

Looking forward to hear from you.

Thanks

Abid

abidv  Monday, March 24, 2008 6:04 AM

Abib, sory for my very late reply, but for the record here is my solution.

First take a look at http://msdn.microsoft.com/en-us/library/ms228767(VS.80).aspx

I manualy created the zip file, based on some examples i found on my computer. so you can create the zipfiles yourself and place them on the template location for your visual studio installation.

(see Visual Studio, Tools, Options, Projects and solutions, Visual Studio user project templates location.

Place the zip file at that location.

The BTSProject.vstemplate looks like this:

<VSTemplate Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>Maps</Name>
<Description>Maps</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<DefaultName>Mapsd</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
<TemplateContent>
<Project TargetFileName="BTSProject.btproj" File="BTSProject.btproj" ReplaceParameters="true">
</Project>
</TemplateContent>
</VSTemplate>

the BTSProject.btproj is based on the project im am trying to automate, so base that on your reference implementation.

Kees

Kees Wouters  Sunday, May 18, 2008 8:26 AM

You can use google to search for other answers

Custom Search

More Threads

• Always publish release build
• MSI Installer Report
• Custom Guidance Package Deployment
• Cant' install "Guidance Automation Extensions" ...
• T4 Editor beta available!
• Use of ExpressionEvaluatorValueProvider in VS2008
• Using IAssetReferenceService
• Service Factory ( Data Access ) - Handling with transactions
• How to change which window form get executed first ?
• Define sequence of Recipes and VSTemplates execution