You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## How to declare project capabilities in your project
31
+
## Filtering MEF parts via capabilities
32
+
33
+
Classes exported via MEF can declare the project capabilities under which they apply. See [MEF](mef.md) for more information.
34
+
35
+
## Defining capabilities via MSBuild
30
36
31
37
Project capabilities can be declared in several ways, the easiest of which
32
-
being to add this MSBuild item to your .targets file:
38
+
being to add this MSBuild item to your `.targets` file:
33
39
34
40
```xml
35
41
<ItemGroup>
36
42
<ProjectCapabilityInclude="MyOwnCapability" />
37
43
</ItemGroup>
38
44
```
39
45
46
+
## Defining fixed capabilities for a project type
47
+
48
+
Some capabilities are static/fixed for a given project type. These capabilities should be defined directly on the project type registration.
49
+
50
+
For example:
51
+
52
+
```csharp
53
+
[assembly: ProjectTypeRegistration(
54
+
projectTypeGuid:MyProjectType.Guid,
55
+
displayName:"#1",
56
+
displayProjectFileExtensions:"#2",
57
+
defaultProjectExtension:"myproj",
58
+
language:"MyLang",
59
+
resourcePackageGuid:MyPackage.PackageGuid,
60
+
Capabilities="MyProject; AnotherCapability")] // Define capabilities here
61
+
```
62
+
63
+
Capabilities defined via the `ProjectTypeRegistrationAttribute.Capabilities` property are available on all projects loaded for that project type. Multiple values are separated by semicolon (`;`).
64
+
65
+
Sometimes you'll need capabilities to be defined very early in a project's lifecycle. These fixed capabilities are available from
66
+
40
67
## Viewing a project's capabilities
41
68
42
69
To see the capabilities a CPS project defines, add the `DiagnoseCapabilities` project capability to turn on a tree in the VS Solution Explorer that lists all capabilities of the project:
@@ -96,7 +123,7 @@ It's very important that project capabilities you define fit this criteria:
96
123
- Bad: `CS`
97
124
- May include a version number, when necessary, but is usually discouraged.
98
125
99
-
###Dynamic project capabilities
126
+
## Dynamic project capabilities
100
127
101
128
Capablities of a project can be changed without reloading the project.
102
129
Read more about [dynamic project capabilities](dynamicCapabilities.md).
0 commit comments