0

I know that I can look into properties,TargetPath, TargetDir, TargetFileName, by right clicking on a project and checking out it's properties but I need to do this programatically. Any help would be very much appreciated.

jshaf
  • 309
  • 1
  • 18

1 Answers1

0

You can get such properties (using the selected startup project as an example) starting with the following code:

Project startupProject = DTE.Solution.Item(((DTE.Solution.SolutionBuild as SolutionBuild2).StartupProjects as object[])[0]);
Properties p = startupProject.ConfigurationManager.ActiveConfiguration.Properties;
Sergey Vlasov
  • 26,641
  • 3
  • 64
  • 66
  • what module do I include to access the Project and Properties class? – jshaf Nov 30 '16 at 17:29
  • 1
    EnvDTE.dll - it's a standard module for any Visual Studio extension. See https://msdn.microsoft.com/en-us/library/envdte.project.aspx and https://msdn.microsoft.com/en-us/library/envdte.properties.aspx – Sergey Vlasov Dec 01 '16 at 09:54
  • Sergey Vlasov this method seems to work great until I get this recurring error: A first chance exception of type Microsoft.Build.Exceptions.InvalidProjectFileException' occurred in Microsoft.Build.dll – jshaf Dec 06 '16 at 17:53