Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > How to Add Additional folders in multiproject template
 

How to Add Additional folders in multiproject template

I want to add some additonal folders with my project folders through vs template wizard.I have a solution with four projects in it,now by using export template i successfully makes the projects templates but I also want to add some additional folders to be created when my template is clicked

My Multiproject .vstemplate file is:-

<VSTemplate Version="2.0.0"

xmlns="http://schemas.microsoft.com/developer/vstemplate/2005"

Type="ProjectGroup">

<TemplateData>

<Name>project test</Name>

<Description>Two great templates.</Description>

<ProjectType>CSharp</ProjectType>

<ProjectSubType>

</ProjectSubType>

<CreateNewFolder>false</CreateNewFolder>

<LocationField>Enabled</LocationField>

<EnableLocationBrowseButton>true</EnableLocationBrowseButton>

<Icon>fsapp.ico</Icon>

</TemplateData>

<TemplateContent>

<ProjectCollection>

<ProjectTemplateLink

ProjectName="Project1">

projectfolder\folder12\Project1\MyTemplate.vstemplate</ProjectTemplateLink>

<ProjectTemplateLink

ProjectName="Project2">

projectfolder\folder12\Project2\MyTemplate.vstemplate</ProjectTemplateLink>

<ProjectTemplateLink

ProjectName="Project3">

projectfolder\folder12\Project3\MyTemplate.vstemplate

</ProjectTemplateLink>

<ProjectTemplateLink

ProjectName="Project4">

projectfolder\folder12\Project4\MyTemplate.vstemplatete

</ProjectTemplateLink>

</ProjectCollection>

</TemplateContent>

</VSTemplate>

I want directory structure like:

Project folder/Folder1/folder11,folder12,folder13,folder14 and in folder12, i want my .sln file and project folder.Is it Possible

Plz reply ASAP

Monesh  Monday, May 21, 2007 8:39 AM

If you want to have different solution folders you should use the SolutionFolder elements in your solution .vstemplate.

<TemplateContent>

<ProjectCollection>

<SolutionFolder Name="SampleFolder">

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

</SolutionFolder>

<SolutionFolder Name="Other Projects" />

<SolutionFolder Name="WebSites">

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

</SolutionFolder>

</ProjectCollection>

</TemplateContent>

However if you want to have folders into a project, you should modify your *project*.vstemplate using something like this:

<TemplateContent>

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

<Folder Name="Foo">

<ProjectItem ReplaceParameters="true">Properties\AssemblyInfo.cs</ProjectItem>

</Folder>

</Project>

</TemplateContent>

Here you've the vstemplate documentation

http://msdn2.microsoft.com/en-us/library/31cdwx28(VS.80).aspx

Also when you create a new guidance package, the default template have different samples of how you can define your .vstemplates.

hope it helps.

Jose Escrich  Wednesday, May 30, 2007 6:20 PM

Hi Monesh,

I asuume you don't really want these third-party DLLs to be included as items in your project but you want just to have them in a folder whitin your solution structure that you could use to add a reference from your project, etc.

If so then vstemplates won't help much in this regard and you will need to copy them programatically as part of the unfolding of your solution by using a custom action to copy files from -for example- your guidance package running folder to the target solution folder hierarchy.

HTH,

-Victor.

vga  Friday, June 01, 2007 4:25 PM

If you want to have different solution folders you should use the SolutionFolder elements in your solution .vstemplate.

<TemplateContent>

<ProjectCollection>

<SolutionFolder Name="SampleFolder">

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

</SolutionFolder>

<SolutionFolder Name="Other Projects" />

<SolutionFolder Name="WebSites">

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

</SolutionFolder>

</ProjectCollection>

</TemplateContent>

However if you want to have folders into a project, you should modify your *project*.vstemplate using something like this:

<TemplateContent>

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

<Folder Name="Foo">

<ProjectItem ReplaceParameters="true">Properties\AssemblyInfo.cs</ProjectItem>

</Folder>

</Project>

</TemplateContent>

Here you've the vstemplate documentation

http://msdn2.microsoft.com/en-us/library/31cdwx28(VS.80).aspx

Also when you create a new guidance package, the default template have different samples of how you can define your .vstemplates.

hope it helps.

Jose Escrich  Wednesday, May 30, 2007 6:20 PM

Hello jose

Thanks for responding on my problem,

I want to add additional folder which contains third party dll files.These folder are doesnot contain any csproj file.And by the help of solution folder how could i add my dll files.I put these folders in my template.zip file but they are not created at location.

And there are lots of disadvantages of multiproject vstemplate.

Can it is possible wit GAT.

Plz guide me.

Thanks

Monesh  Thursday, May 31, 2007 10:44 AM

Hi Monesh,

I asuume you don't really want these third-party DLLs to be included as items in your project but you want just to have them in a folder whitin your solution structure that you could use to add a reference from your project, etc.

If so then vstemplates won't help much in this regard and you will need to copy them programatically as part of the unfolding of your solution by using a custom action to copy files from -for example- your guidance package running folder to the target solution folder hierarchy.

HTH,

-Victor.

vga  Friday, June 01, 2007 4:25 PM

Monesh/Jose,

You can actually add the DLL assembly references programmtically as well. The CSPROJ (all VS project containers) are just XML - like the VSTEMPLATE files. One the reasons for this is to remove the burdin of a proprietay/binary format for the projects is to provide looser coupling between the VS env and the solution files - so you or 3rd-parties, the VS extensionVSIP stuff, etc can manipulate the solition file containers (like CSPOJ files).

Your CSPROJ elements will look like this:

<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>

Make the refs and look at the CSPROJ file in Notepad, XMLSpy, VS (any XML/text editor) as an example. We're doing similar things in our environment after I've been digging around in these XML files to make our code generation as complete as possible - even as far as applying SNK files.setting the "Sign this assembly" project property. A word of advice on the latter; you'll want to include the SNK file specification in your project's VSTEMPLATE file, as well as adding these settings to your CSPROJ file (again, look at your CSPROJ file for an example):

<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>[YourSnkFileName].snk</AssemblyOriginatorKeyFile>
<DelaySign>false</DelaySign>

In order to complete this programmatic process however, you'll also need to add these (often missed) lines to your CSPROJ file:

<ItemGroup>
<None Include="[YourSnkFileName].snk" />
</ItemGroup>

These little tricks (actually just a little "uner-the-hood" investigation/knowledge of MS's intentions) lets you do as much during coe generation as possible; you can use familiar .Net XML commands to navigate/update the CSPROJ file. Don't even need GAX for many things; just regular VS templates/starter kits/simple Wizard programs.
Galaxis  Sunday, May 04, 2008 4:58 PM
vga wrote:

Hi Monesh,

I asuume you don't really want these third-party DLLs to be included as items in your project but you want just to have them in a folder whitin your solution structure that you could use to add a reference from your project, etc.

If so then vstemplates won't help much in this regard and you will need to copy them programatically as part of the unfolding of your solution by using a custom action to copy files from -for example- your guidance package running folder to the target solution folder hierarchy.

HTH,

-Victor.



Hi Victor,

I have the same needs thant Monesh.
So I am building a custom action to copy files from the guidance package running folder to the target solution folder hierarchy. But how I get the guidance package running folder and the target solution folder ? Can you post some example code ?

Thanks by advance,

Nicolas
nmousson  Monday, May 05, 2008 8:24 AM

You can use google to search for other answers

Custom Search

More Threads

• GAX 1.4 won't install
• Error installing Mobile Client Software Factory on Vista - Cannot Connect to IIS
• SCSF/CAB - Module & View Loading Best Practice?
• Where is the ConditionalCoordinator to the latest GAX release (Feb)?
• <ProjectGuid>{$WebGuidProp$}</ProjectGuid> Ignored -- very stragne behaviour
• How to set focus on "No" button of the MsgBox in VB.NET
• Help me decide: how to generate my Data Access Layer ( please :)
• Is it possible to call an action from a Converter ?
• Issues with VS Team System 2008 Dev Edition
• Web Service Software Factory (WCF) - cannot add service reference