locked
Programmatically access project's 'property page' (using DTE?) RRS feed

  • Question

  • Hello!

    We have installed a Visual Studio plugin (extensibility) that allow our users to launch devenv and automatically add a file to the solution. For example, 'startVS notepad.exe' will start Visual Studio and add 'notepad.exe' to the solution.

    Users then right-click the 'notepad.exe' in Solution Explorer and select 'Properties'. The property page comes up. From there, users changes the 'Argument' property.

    What I'm trying to do is programmatically modify the 'argument' property.

    The problem is I cannot find how to access these properties with DTE. I looked at the values of 'DTE.Solution.Properties.Item', but it doesn't look like it's there.

    I looked in the solution file, and the information is there under the project 'notepad.exe' (along with other properties I might want to access too). 

    Does anyone know a way I could programmatically access and modify these properties, (without having to parse the sln file)?

    Thanks!

    J-R
    =o)
    Tuesday, September 25, 2012 3:08 PM

Answers

  • Hello!

    I already tried that.

    The thing is that properties available for types 'Project Exe' in the 'Property Pages' (like 'Arguments', 'Working Directory', etc) is not available using 'dte.Solution.Projects.Item(1).Properties', and 'Project.ConfigurationManager.ActiveConfiguration.Properties' is actually 'null'.

    For now, what I'm doing is hacking the *.sln file to modify or add the property I need. It's ugly and opens the door to a whole bunch of problems, but it works. Still hope there's a better 

    • Marked as answer by Goofyb Wednesday, October 10, 2012 2:01 PM
    Thursday, September 27, 2012 11:54 AM

All replies

  • Hi Goofyb,

    You can try using the codes as following below to get the properties:

    EnvDTE.Project propject = dte.Solution.Projects.Item(1);
    EnvDTE.Properties properties = propject.ConfigurationManager.ActiveConfiguration.Properties;

    We can set the value of the property which we want to modify.

    Here is an article about DTE Properties Collections which you can refer to:

    http://msdn.microsoft.com/en-us/library/ms165641.aspx

    Best regards,


    Ego [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, September 27, 2012 8:28 AM
  • Hello!

    I already tried that.

    The thing is that properties available for types 'Project Exe' in the 'Property Pages' (like 'Arguments', 'Working Directory', etc) is not available using 'dte.Solution.Projects.Item(1).Properties', and 'Project.ConfigurationManager.ActiveConfiguration.Properties' is actually 'null'.

    For now, what I'm doing is hacking the *.sln file to modify or add the property I need. It's ugly and opens the door to a whole bunch of problems, but it works. Still hope there's a better 

    • Marked as answer by Goofyb Wednesday, October 10, 2012 2:01 PM
    Thursday, September 27, 2012 11:54 AM
  • You can modify or add the property using MSBuild.

    More information you can refer to:

    http://msdn.microsoft.com/en-us/library/dd293626.aspx

    And I think what the article said as following below is useful to you.

    http://msdn.microsoft.com/en-us/library/ff770593.aspx

    Monday, October 1, 2012 12:18 AM
  • Hello!

    Unfortunately (for reasons I do not dare to explain), I cannot use the MSBuild for that purpose.

    In the end, I did end up Hacking the solution file.

    Thank you all for your time and ideas, it is appreciated.
    =o)

    Wednesday, October 10, 2012 2:01 PM