I am using reference of EnvDTE80 in my code to open a visual studio solution and then traverse through the projects present in it. I am new to this and am using the below code snippet : Firstly defined an object of the below type :
EnvDTE80.DTE2 dte2;
then tried to access the solution through it :
Solution2 solution = dte2.Solution as E2.Solution2;
if (solution == null)
{
return;
}
Projects projects = solution.Projects;
foreach (E1.Project project in projects)
{
Property outputPath =
project.ConfigurationManager.ActiveConfiguration.Properties
.Item("outputPath");
outputPath.Value = buildFolderPath;
project.Save(project.FullName);
}
Basically I am trying to change the project output path through the code snippet and whenever I run the code I get an error stating that "Object Reference not set to an instance of an object". The "dte2" object is null.
Any suggestions how to initialize it ?