3. Load our com dlls into the project.
The project template includes a proj file where you specify the references to be included with the project:
<!-- This sections specifies references for the project. -->
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.Tools.Applications.Runtime.v9.0" />
<Reference Include="ShapeAppCSharpProxy, Version=2.0.0.0, Culture=neutral, PublicKeyToken=3c3c0c46dd27dbcf, processorArchitecture=MSIL">
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="System" />
<Reference Include="System.AddIn">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
Public Sub CreateProjectFromTemplateOrOpenExisting(ByVal TemplateName As String, ByVal ProjectFilePath As String)
Dim lang As String = "VisualBasic"
'determine the language - must have CSharp template to use this
If ProjectFilePath.Contains(".csproj") Then
lang = "CSharp"
End If
'IF the dte does not already exit, create it
If Me.mDTE Is Nothing Then
Me.ShowVSTAIDE(True)
End If
'create a solution in the DTE
Dim sol As EnvDTE80.Solution2 = CType(mDTE.Solution, EnvDTE80.Solution2)
'If the project exists
If System.IO.File.Exists(ProjectFilePath) Then
'open the file
Me.mProject = mDTE.Solution.AddFromFile(ProjectFilePath, True)
Me.mProjectPath = ProjectFilePath
Else 'the project doesn't exist, create a new one
'get the path to create the project in
Dim projectPath As String = System.IO.Path.GetDirectoryName(ProjectFilePath)
'select the template to use
Dim templatePath As String = sol.GetProjectTemplate(TemplateName, lang)
'IF the specified project isn't available throw an exception
If templatePath = String.Empty Then
Throw New System.IO.FileNotFoundException("Project template has not been registered.")
End If
'create the a new project in the specified path based on the specified template
Me.mProject = Me.mDTE.Solution.AddFromTemplate(templatePath, projectPath, _
System.IO.Path.GetFileName(ProjectFilePath), True)
Me.mProjectPath = ProjectFilePath
End If
End Sub