Skip to content

Commit c1bc8c7

Browse files
authored
Merge pull request #377 from drewnoakes/doc-capability-provider
Add more docs around capability providers and diagnostics
2 parents 1cb9d54 + 237897d commit c1bc8c7

3 files changed

Lines changed: 46 additions & 6 deletions

File tree

25.1 KB
Loading

doc/overview/about_project_capabilities.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ file extension does not help if you want to check for WPF vs. WinForms
66
vs. Windows 8 XAML, for example. There are a great many different aspects
77
to a project that may be present regardless of language. Do you want code
88
that runs against any Windows 8 targeting project regardless of language?
9-
Do you want to target just Javascript Win8 projects but not LightSwitch
9+
Do you want to target just JavaScript Win8 projects but not LightSwitch
1010
JS projects? Project capability checks are the answer.
1111

12+
## Checking capabilities
13+
1214
The presence of some capability can be detected on a given project with
1315
code such as:
1416

@@ -26,15 +28,54 @@ method in order to test for combinations of capabilities (including
2628
AND, OR, NOT logic). Read more about [the supported syntax and
2729
operators](https://msdn.microsoft.com/library/microsoft.visualstudio.shell.interop.ivsbooleansymbolexpressionevaluator.evaluateexpression.aspx).
2830

29-
## 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
3036

3137
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:
3339

3440
```xml
35-
<ProjectCapability Include="MyOwnCapability" />
41+
<ItemGroup>
42+
<ProjectCapability Include="MyOwnCapability" />
43+
</ItemGroup>
44+
```
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
3661
```
3762

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+
67+
## Viewing a project's capabilities
68+
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:
70+
71+
```xml
72+
<ItemGroup>
73+
<ProjectCapability Include="DiagnoseCapabilities" />
74+
</ItemGroup>
75+
```
76+
77+
![alt text](../Images/diagnose-capabilities-tree.png)
78+
3879
## Common project capabilities and where they are defined
3980

4081
### Existing project capabilities
@@ -82,7 +123,7 @@ It's very important that project capabilities you define fit this criteria:
82123
- Bad: `CS`
83124
- May include a version number, when necessary, but is usually discouraged.
84125

85-
### Dynamic project capabilities
126+
## Dynamic project capabilities
86127

87128
Capablities of a project can be changed without reloading the project.
88129
Read more about [dynamic project capabilities](dynamicCapabilities.md).

doc/overview/dynamicCapabilities.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ a project to be adjusted dynamically based on features/NuGet packages being used
1010
For example, WPF features can be turned on, only because the project references WPF related packages,
1111
instead of depending on which template was used when the project was created.
1212

13-
1413
## Capabilities are now coming from dataflows
1514

1615
In both unconfigured project and configured project scopes, capabilities are no longer a fixed set of strings.

0 commit comments

Comments
 (0)