Skip to content

Commit 814b144

Browse files
authored
Fix indent
1 parent f2f4f54 commit 814b144

File tree

1 file changed

+133
-140
lines changed

1 file changed

+133
-140
lines changed

docs/extensibility/creating-a-basic-project-system-part-2.md

Lines changed: 133 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -53,35 +53,35 @@ By using a Visual Studio template (*.vstemplate* file) instead of a basic projec
5353
5454
4. Replace the contents of *SimpleProject.vstemplate* with the following code.
5555
56-
```xml
57-
<VSTemplate Version="2.0.0" Type="Project"
58-
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
59-
<TemplateData>
60-
<Name>SimpleProject Application</Name>
61-
<Description>
62-
A project for creating a SimpleProject application
56+
```xml
57+
<VSTemplate Version="2.0.0" Type="Project"
58+
xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
59+
<TemplateData>
60+
<Name>SimpleProject Application</Name>
61+
<Description>
62+
A project for creating a SimpleProject application
6363
</Description>
6464
<Icon>SimpleProject.ico</Icon>
6565
<ProjectType>SimpleProject</ProjectType>
66-
</TemplateData>
67-
<TemplateContent>
68-
<Project File="SimpleProject.myproj" ReplaceParameters="true">
69-
<ProjectItem ReplaceParameters="true" OpenInEditor="true">
70-
Program.cs
71-
</ProjectItem>
72-
<ProjectItem ReplaceParameters="true" OpenInEditor="false">
66+
</TemplateData>
67+
<TemplateContent>
68+
<Project File="SimpleProject.myproj" ReplaceParameters="true">
69+
<ProjectItem ReplaceParameters="true" OpenInEditor="true">
70+
Program.cs
71+
</ProjectItem>
72+
<ProjectItem ReplaceParameters="true" OpenInEditor="false">
7373
AssemblyInfo.cs
74-
</ProjectItem>
75-
</Project>
76-
</TemplateContent>
77-
</VSTemplate>
78-
```
74+
</ProjectItem>
75+
</Project>
76+
</TemplateContent>
77+
</VSTemplate>
78+
```
7979
8080
5. In the **Properties** window, select all five files in the *\\Templates\Projects\SimpleProject\\* folder and set the **Build Action** to **ZipProject**.
8181
82-
![Simple Project Folder](../extensibility/media/simpproj2.png "SimpProj2")
82+
![Simple Project Folder](../extensibility/media/simpproj2.png "SimpProj2")
8383
84-
The \<TemplateData> section determines the location and appearance of the SimpleProject project type in the **New Project** dialog box, as follows:
84+
The \<TemplateData> section determines the location and appearance of the SimpleProject project type in the **New Project** dialog box, as follows:
8585
8686
- The \<Name> element names the project template to be SimpleProject Application.
8787
@@ -154,7 +154,7 @@ By using a Visual Studio template (*.vstemplate* file) instead of a basic projec
154154
155155
4. Rebuild the SimpleProject project.
156156
157-
The build step to create the *.zip* project file should resemble the following example.
157+
The build step to create the *.zip* project file should resemble the following example.
158158
159159
```
160160
ZipProjects:
@@ -169,12 +169,12 @@ ZipProjects:
169169
```
170170
171171
## Deploy a Visual Studio template
172-
Visual Studio templates do not contain path information. Therefore, the template *.zip* file must be deployed to a location that is known to Visual Studio. The location of the ProjectTemplates folder is typically *<%LOCALAPPDATA%>\Microsoft\VisualStudio\14.0Exp\ProjectTemplates*.
172+
Visual Studio templates do not contain path information. Therefore, the template *.zip* file must be deployed to a location that is known to Visual Studio. The location of the ProjectTemplates folder is typically *<%LOCALAPPDATA%>\Microsoft\VisualStudio\14.0Exp\ProjectTemplates*.
173173
174-
To deploy your project factory, the installation program must have administrator privileges. It deploys templates under the Visual Studio installation node: *...\Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates*.
174+
To deploy your project factory, the installation program must have administrator privileges. It deploys templates under the Visual Studio installation node: *...\Microsoft Visual Studio 14.0\Common7\IDE\ProjectTemplates*.
175175
176176
## Test a Visual Studio template
177-
Test your project factory to see whether it creates a project hierarchy by using the Visual Studio template.
177+
Test your project factory to see whether it creates a project hierarchy by using the Visual Studio template.
178178
179179
1. Reset the Visual Studio SDK experimental instance.
180180
@@ -190,16 +190,16 @@ ZipProjects:
190190
191191
5. You should see a new instance of SimpleProject.
192192
193-
![Simple Project New Instance](../extensibility/media/simpproj2_newproj.png "SimpProj2_NewProj")
193+
![Simple Project New Instance](../extensibility/media/simpproj2_newproj.png "SimpProj2_NewProj")
194194
195-
![My Project New Instance](../extensibility/media/simpproj2_myproj.png "SimpProj2_MyProj")
195+
![My Project New Instance](../extensibility/media/simpproj2_myproj.png "SimpProj2_MyProj")
196196
197197
## Create a project type child node
198-
You can add a child node to a project type node in the **New Project** dialog box. For example, for the SimpleProject project type, you could have child nodes for console applications, window applications, web applications, and so on.
198+
You can add a child node to a project type node in the **New Project** dialog box. For example, for the SimpleProject project type, you could have child nodes for console applications, window applications, web applications, and so on.
199199
200-
Child nodes are created by altering the project file and adding \<OutputSubPath> children to the \<ZipProject> elements. When a template is copied during build or deployment, every child node becomes a subfolder of the project templates folder.
200+
Child nodes are created by altering the project file and adding \<OutputSubPath> children to the \<ZipProject> elements. When a template is copied during build or deployment, every child node becomes a subfolder of the project templates folder.
201201
202-
This section shows how to create a Console child node for the SimpleProject project type.
202+
This section shows how to create a Console child node for the SimpleProject project type.
203203
204204
1. Rename the *\\Templates\Projects\SimpleProject\\* folder to *\\Templates\Projects\ConsoleApp\\*.
205205
@@ -221,20 +221,20 @@ ZipProjects:
221221
222222
```
223223
<ZipProject Include="Templates\Projects\ConsoleApp\AssemblyInfo.cs">
224-
<OutputSubPath>Console</OutputSubPath>
225-
</ZipProject>
226-
<ZipProject Include="Templates\Projects\ConsoleApp\Program.cs">
227-
<OutputSubPath>Console</OutputSubPath>
228-
</ZipProject>
229-
<ZipProject Include="Templates\Projects\ConsoleApp\SimpleProject.myproj">
230-
<OutputSubPath>Console</OutputSubPath>
231-
</ZipProject>
232-
<ZipProject Include="Templates\Projects\ConsoleApp\SimpleProject.vstemplate">
233-
<OutputSubPath>Console</OutputSubPath>
234-
</ZipProject>
235-
<ZipProject Include="Templates\Projects\ConsoleApp\SimpleProject.ico">
236-
<OutputSubPath>Console</OutputSubPath>
237-
</ZipProject>
224+
<OutputSubPath>Console</OutputSubPath>
225+
</ZipProject>
226+
<ZipProject Include="Templates\Projects\ConsoleApp\Program.cs">
227+
<OutputSubPath>Console</OutputSubPath>
228+
</ZipProject>
229+
<ZipProject Include="Templates\Projects\ConsoleApp\SimpleProject.myproj">
230+
<OutputSubPath>Console</OutputSubPath>
231+
</ZipProject>
232+
<ZipProject Include="Templates\Projects\ConsoleApp\SimpleProject.vstemplate">
233+
<OutputSubPath>Console</OutputSubPath>
234+
</ZipProject>
235+
<ZipProject Include="Templates\Projects\ConsoleApp\SimpleProject.ico">
236+
<OutputSubPath>Console</OutputSubPath>
237+
</ZipProject>
238238
```
239239
240240
7. Add this \<PropertyGroup> to the project file:
@@ -248,7 +248,7 @@ ZipProjects:
248248
8. Save the project file and reload the project.
249249
250250
## Test the project type child node
251-
Test the modified project file to see whether the **Console** child node appears in the **New Project** dialog box.
251+
Test the modified project file to see whether the **Console** child node appears in the **New Project** dialog box.
252252
253253
1. Run the **Reset the Microsoft Visual Studio Experimental Instance** tool.
254254
@@ -260,9 +260,9 @@ ZipProjects:
260260
261261
5. Click **Cancel** and stop debugging.
262262
263-
![Simple Project Rollup](../extensibility/media/simpproj2_rollup.png "SimpProj2_Rollup")
263+
![Simple Project Rollup](../extensibility/media/simpproj2_rollup.png "SimpProj2_Rollup")
264264
265-
![Simple Project Console Node](../extensibility/media/simpproj2_subfolder.png "SimpProj2_Subfolder")
265+
![Simple Project Console Node](../extensibility/media/simpproj2_subfolder.png "SimpProj2_Subfolder")
266266
267267
## Substitute project template parameters
268268
[Creating a basic project system, part 1](../extensibility/creating-a-basic-project-system-part-1.md) showed how to overwrite the `ProjectNode.AddFileFromTemplate` method to do a basic kind of template parameter substitution. This section teaches how to use the more sophisticated Visual Studio template parameters.
@@ -348,110 +348,103 @@ The property page you create in this section lets you alter and save these proje
348348
349349
1. In the *SimpleProjectPackage.cs* file, add this `ProvideObject` attribute to the `SimpleProjectPackage` class:
350350
351-
```
352-
[ProvideObject(typeof(GeneralPropertyPage))]
353-
public sealed class SimpleProjectPackage : ProjectPackage
354-
```
351+
```
352+
[ProvideObject(typeof(GeneralPropertyPage))]
353+
public sealed class SimpleProjectPackage : ProjectPackage
354+
```
355355
356356
This registers the property page class `GeneralPropertyPage` with COM.
357357
358358
2. In the *SimpleProjectNode.cs* file, add these two overridden methods to the `SimpleProjectNode` class:
359359
360-
```csharp
361-
protected override Guid[] GetConfigurationIndependentPropertyPages()
362-
{
363-
Guid[] result = new Guid[1];
364-
result[0] = typeof(GeneralPropertyPage).GUID;
365-
return result;
366-
}
367-
protected override Guid[] GetPriorityProjectDesignerPages()
368-
{
369-
Guid[] result = new Guid[1];
370-
result[0] = typeof(GeneralPropertyPage).GUID;
360+
```csharp
361+
protected override Guid[] GetConfigurationIndependentPropertyPages()
362+
{
363+
Guid[] result = new Guid[1];
364+
result[0] = typeof(GeneralPropertyPage).GUID;
371365
return result;
372-
}
373-
```
366+
}
367+
protected override Guid[] GetPriorityProjectDesignerPages()
368+
{
369+
Guid[] result = new Guid[1];
370+
result[0] = typeof(GeneralPropertyPage).GUID;
371+
return result;
372+
}
373+
```
374374
375375
Both of these methods return an array of property page GUIDs. The GeneralPropertyPage GUID is the only element in the array, so the **Property Pages** dialog box will show only one page.
376376
377377
3. Add a class file named *GeneralPropertyPage.cs* to the SimpleProject project.
378378
379379
4. Replace the contents of this file by using the following code:
380380
381-
```csharp
382-
using System;
383-
using System.Runtime.InteropServices;
384-
using Microsoft.VisualStudio;
385-
using Microsoft.VisualStudio.Project;
386-
using System.ComponentModel;
387-
388-
namespace SimpleProject
389-
{
390-
[ComVisible(true)]
391-
[Guid("6BC7046B-B110-40d8-9F23-34263D8D2936")]
392-
public class GeneralPropertyPage : SettingsPage
393-
{
394-
private string assemblyName;
395-
private OutputType outputType;
396-
private string defaultNamespace;
397-
398-
public GeneralPropertyPage()
399-
{
400-
this.Name = "General";
401-
}
402-
403-
[Category("AssemblyName")]
404-
[DisplayName("AssemblyName")]
405-
[Description("The output file holding assembly metadata.")]
406-
public string AssemblyName
407-
{
408-
get { return this.assemblyName; }
409-
}
410-
[Category("Application")]
411-
[DisplayName("OutputType")]
412-
[Description("The type of application to build.")]
413-
public OutputType OutputType
414-
{
415-
get { return this.outputType; }
416-
set { this.outputType = value; this.IsDirty = true; }
417-
}
418-
[Category("Application")]
419-
[DisplayName("DefaultNamespace")]
420-
[Description("Specifies the default namespace for added items.")]
421-
public string DefaultNamespace
422-
{
423-
get { return this.defaultNamespace; }
424-
set { this.defaultNamespace = value; this.IsDirty = true; }
425-
}
426-
427-
protected override void BindProperties()
428-
{
429-
this.assemblyName = this.ProjectMgr.GetProjectProperty(
430-
"AssemblyName", true);
431-
this.defaultNamespace = this.ProjectMgr.GetProjectProperty(
432-
"RootNamespace", false);
433-
434-
string outputType = this.ProjectMgr.GetProjectProperty(
435-
"OutputType", false);
436-
this.outputType =
437-
(OutputType)Enum.Parse(typeof(OutputType), outputType);
438-
}
439-
440-
protected override int ApplyChanges()
441-
{
442-
this.ProjectMgr.SetProjectProperty(
443-
"AssemblyName", this.assemblyName);
444-
this.ProjectMgr.SetProjectProperty(
445-
"OutputType", this.outputType.ToString());
446-
this.ProjectMgr.SetProjectProperty(
447-
"RootNamespace", this.defaultNamespace);
448-
this.IsDirty = false;
449-
450-
return VSConstants.S_OK;
451-
}
452-
}
453-
}
454-
```
381+
```csharp
382+
using System;
383+
using System.Runtime.InteropServices;
384+
using Microsoft.VisualStudio;
385+
using Microsoft.VisualStudio.Project;
386+
using System.ComponentModel;
387+
388+
namespace SimpleProject
389+
{
390+
[ComVisible(true)]
391+
[Guid("6BC7046B-B110-40d8-9F23-34263D8D2936")]
392+
public class GeneralPropertyPage : SettingsPage
393+
{
394+
private string assemblyName;
395+
private OutputType outputType;
396+
private string defaultNamespace;
397+
398+
public GeneralPropertyPage()
399+
{
400+
this.Name = "General";
401+
}
402+
403+
[Category("AssemblyName")]
404+
[DisplayName("AssemblyName")]
405+
[Description("The output file holding assembly metadata.")]
406+
public string AssemblyName
407+
{
408+
get { return this.assemblyName; }
409+
}
410+
[Category("Application")]
411+
[DisplayName("OutputType")]
412+
[Description("The type of application to build.")]
413+
public OutputType OutputType
414+
{
415+
get { return this.outputType; }
416+
set { this.outputType = value; this.IsDirty = true; }
417+
}
418+
[Category("Application")]
419+
[DisplayName("DefaultNamespace")]
420+
[Description("Specifies the default namespace for added items.")]
421+
public string DefaultNamespace
422+
{
423+
get { return this.defaultNamespace; }
424+
set { this.defaultNamespace = value; this.IsDirty = true; }
425+
}
426+
427+
protected override void BindProperties()
428+
{
429+
this.assemblyName = this.ProjectMgr.GetProjectProperty("AssemblyName", true);
430+
this.defaultNamespace = this.ProjectMgr.GetProjectProperty("RootNamespace", false);
431+
432+
string outputType = this.ProjectMgr.GetProjectProperty("OutputType", false);
433+
this.outputType = (OutputType)Enum.Parse(typeof(OutputType), outputType);
434+
}
435+
436+
protected override int ApplyChanges()
437+
{
438+
this.ProjectMgr.SetProjectProperty("AssemblyName", this.assemblyName);
439+
this.ProjectMgr.SetProjectProperty("OutputType", this.outputType.ToString());
440+
this.ProjectMgr.SetProjectProperty("RootNamespace", this.defaultNamespace);
441+
this.IsDirty = false;
442+
443+
return VSConstants.S_OK;
444+
}
445+
}
446+
}
447+
```
455448
456449
The `GeneralPropertyPage` class exposes the three public properties AssemblyName, OutputType, and RootNamespace. Because AssemblyName has no set method, it is displayed as a read-only property. OutputType is an enumerated constant, so it appears as dropdown list.
457450
@@ -465,7 +458,7 @@ The property page you create in this section lets you alter and save these proje
465458
466459
8. Right-click the project node in **Solution Explorer**, and then click **Properties**. The **Property Pages** dialog box is displayed.
467460
468-
![Simple Project Property Page](../extensibility/media/simpproj2_proppage.png "SimpProj2_PropPage")
461+
![Simple Project Property Page](../extensibility/media/simpproj2_proppage.png "SimpProj2_PropPage")
469462
470463
## Test the project property page
471464
Now you can test whether you can modify and change property values.
@@ -485,4 +478,4 @@ Now you can test whether you can modify and change property values.
485478
7. Reopen the **Property Pages** dialog box and verify that your changes have been persisted.
486479
487480
8. Close the experimental instance of Visual Studio.
488-
![Close the experimental instance](../extensibility/media/simpproj2_proppage2.png "SimpProj2_PropPage2")
481+
![Close the experimental instance](../extensibility/media/simpproj2_proppage2.png "SimpProj2_PropPage2")

0 commit comments

Comments
 (0)