SUMMARY
You can include folders and virtual folders as project
items in the policy file of an Enterprise Template. To do this, you must
identify the project item type for folders or virtual folders as an ELEMENT in
the policy file. When you have included each folder or virtual folder, you can
explicitly constrain or permit that project item type when you create a
policied project.
NOTE: Folders that are used in Visual Basic .NET and Visual C# .NET
projects are physical folders; they correspond to directories on the hard disk.
Folders that are used in Visual C++ .NET projects are virtual folders; no
directory is located on the hard disk.
The following sections explain
how to identify and set policy on folders:
- Add Folder Identifications
Before you can constrain or permit a folder, you must
identify it as an ELEMENT in your policy file. This section explains how to add
an ELEMENT definition for a folder or for a virtual folder. - Add Project Items to a Category
After you add ELEMENT definitions for the project items, you
may constrain or permit them by placing them in a category.
MORE INFORMATION
Add Folder Identifications
You must identify folders (and virtual folders) before you set
policy for them. By default, the policy files that are included with Visual
Studio .NET do not contain identification for folders. This means that if the
policy file for your project specifies POLICYMODE=RESTRICTIVE, and the
project's ELEMENTSET specifies
<DEFAULTACTION>EXCLUDEINCLUDE</DEFAULTACTION>
any unidentified elements, including folders, cause policy reminders to
appear. (If you set POLICYMODE to PERMISSIVE, unidentified elements do not
cause policy reminders to appear.)
NOTE: As an architect, you decide whether to set the POLICYMODE to
RESTRICTIVE or to PERMISSIVE. To treat all unknown items as policy elements,
set the POLICYMODE to RESTRICTIVE. To control only known elements, set the
POLICYMODE to PERMISSIVE. In Visual Studio .NET, the policy file DAP.tdl sets
POLICYMODE to PERMISSIVE.
The following code adds identifications for
folders if you are using Visual Basic .NET or Visual C# .NET, or for virtual
folders if you are using Visual C/C++ .NET.
To add a folder to a Visual Basic .NET or Visual C# .NET
project, follow these steps:
- Open the policy file that your project uses.
- Identify the folder type of the project item. To do this,
add the following ELEMENT definition to the policy file:
<ELEMENT>
<ID>projItemFolder</ID>
<IDENTIFIERS>
<IDENTIFIER>
<TYPE>PROJECTITEM</TYPE>
<IDENTIFIERDATA>
<NAME>Kind</NAME>
<VALUE>{6BB5F8EF-4483-11D3-8BCF-00C04F8EC28C}</VALUE>
</IDENTIFIERDATA>
</IDENTIFIER>
</IDENTIFIERS>
</ELEMENT>
To add a virtual folder to a Visual C/C++ .NET project, follow
these steps:
- Open the policy file that your project uses.
- Identify the folder type of the project item. To do this,
add the following ELEMENT definition to the policy file:
<ELEMENT>
<ID>projItemVirtualFolder</ID>
<IDENTIFIERS>
<IDENTIFIER>
<TYPE>PROJECTITEM</TYPE>
<IDENTIFIERDATA>
<NAME>Kind</NAME>
<VALUE>{6BB5F8F0-4483-11D3-8BCF-00C04F8EC28C}</VALUE>
</IDENTIFIERDATA>
</IDENTIFIER>
</IDENTIFIERS>
</ELEMENT>
You must have the GUID for an item to add its ELEMENT definition. In
this case, the GUID values identify the folder project item and the virtual
folder project item in the IDENTIFIERDATA node in each ELEMENT definition. If
you do not know the GUID value, you can get it through the
Kind property of the
dte.ProjectItem object. For more information, visit the following Microsoft Web
site:
Add Project Items to
a Category
By providing identification for a folder alone, you cannot stop
the generation of policy reminders. You also must include it in every project's
ELEMENTSET either explicitly, by using the an element set's INCLUDE tag, or
implicitly, by using the DEFAULTACTION tag:
<DEFAULTACTION>INCLUDE</DEFAULTACTION>
The best way to do this for folders is to include them as category
members in the category
catCommonProjectItems. This category is explicitly included in every project type in
DAP.tdl. To add project items to a category, follow these steps:
- Open the policy file that your project uses.
- Locate the catCommonProjectItems category.
- Add the folder (or the virtual folder) project items to the
catCommonProjectItems category. The following sample code adds the two types of folder
project items to the category catCommonProjectItems:
<CATEGORY>
<ID>catCommonProjectItems</ID>
:
<CATEGORYMEMBER>projItemFolder</CATEGORYMEMBER>
<CATEGORYMEMBER>projItemVirtualFolder</CATEGORYMEMBER>
</CATEGORY>
NOTE: Although it is easier to include a folder by putting it in a
CATEGORY (as shown in the previous example), you may also explicitly include
the folder in the project's ELEMENTSET.