locked
Adding property sheet to new project with custom wizard RRS feed

  • Question

  • Hello,

    I'm trying to build a custom wizard for new Visual Studio 2010 projects. The custom wizard will essentially create a new VC++ project and add a few of my property sheets to each configuration.

    I have this working well in Visual Studio 2008. In the default.js's AddConfig I simply referenced selProj.Object.Configurations("Debug|Win32"), then set the InheritedPropertySheets field to the property sheet. I did the same for Configurations("Release|Win32").

    With 2010, however, the InheritedPropertySheets field is deprecated. Trying to get or set this field results in an exception. It appears the new way is to call AddPropertySheet method on the VCConfiguration object I get back when I use selProject.Object.Configurations("Debug|Win32"). However, when I try to do that I get the error "Variable uses an Automation type not supported in JScript".

    One thing I've noticed is that if I look at the VCConfiguration's PropertySheets property (there are 3 items, which are the standard property sheets VS includes), I can call AddPropertySheet on those. Doing so would add the property sheet reference to the standard property sheets that VS includes, not to the project configuration.

    Any ideas?

    Wednesday, June 23, 2010 12:14 AM

Answers

  • Hello, Johann

    I am sorry for the lately reply.

    It should work, I have done a test, but my code use C# instead of Jscript, you know it is easy to convert C# to Jscript.

    Please see the following C# code,

                        VCConfiguration VCPrjConfig = VCprj.Configurations.Item("Debug|Win32");

                        IVCCollection propertySheets = VCPrjConfig.PropertySheets;

                        VCPrjConfig.AddPropertySheet("D:\\SecondProps.prop");

    And for a good tutorial for using VCProjectEngine, this link may be a better choice http://blogs.msdn.com/b/visualstudio/archive/2010/01/15/how-to-read-write-the-new-visual-c-project-properties.aspx

    And would you be kind to give me some feedback?

    Hope this helps.

    Thanks

    Chao

    Tuesday, June 29, 2010 2:14 AM

All replies

  • Hi, Johann

    You could trust the VCConfiguration.AddPropertySheet method, unlike VS2008 that the property page have a item that indicates it was added to project configuration.

    All the property sheets will be applied from the bottom to the top in the Property manager, so your property sheet is added to the project configuration.

    See this link for the details of the property sheet evaluation.

    http://blogs.msdn.com/b/vsproject/archive/2009/06/23/inherited-properties-and-property-sheets.aspx

    Thanks

    Chao

    Thursday, June 24, 2010 11:41 AM
  • I am calling AddPropertySheet on the VCConfiguration, but when I do an exception is thrown:

    "Variable uses an Automation type not supported in JScript"

    I tried simply catching that and continuing, but the resulting created project does not have any references to my property sheets.

    Friday, June 25, 2010 11:10 AM
  • Hello, Johann

    I am sorry for the lately reply.

    It should work, I have done a test, but my code use C# instead of Jscript, you know it is easy to convert C# to Jscript.

    Please see the following C# code,

                        VCConfiguration VCPrjConfig = VCprj.Configurations.Item("Debug|Win32");

                        IVCCollection propertySheets = VCPrjConfig.PropertySheets;

                        VCPrjConfig.AddPropertySheet("D:\\SecondProps.prop");

    And for a good tutorial for using VCProjectEngine, this link may be a better choice http://blogs.msdn.com/b/visualstudio/archive/2010/01/15/how-to-read-write-the-new-visual-c-project-properties.aspx

    And would you be kind to give me some feedback?

    Hope this helps.

    Thanks

    Chao

    Tuesday, June 29, 2010 2:14 AM
  • Hi, Johann

    Could you give me some feedback?

    Thanks

    Chao

    Wednesday, June 30, 2010 8:32 AM
  • Hi Chao,

    So, I was using the Custom Wizard project that uses JScript with default.js. I didn't know how easy it was to do a custom wizard in C#. I recreated my project using C# and it's working great.

    One issue I had was having the same DLL work for both VS 2008 and VS 2010. With 2008, project.Object is a VCProject, but with 2010 it's a VSProjectShim. I couldn't find an easy way to reference the VSProjectShim, so I had to use reflection to call the correct methods.

    Anyway, the same DLL now works for both 2008 and 2010 (with a little reflection hackerage). Thank's for pointing out that I didn't have to use JScript!

    Wednesday, June 30, 2010 4:08 PM
  • Hi Chao,

    I trying the following code in JS i get "Object doesn't support this property or method"
    I m using VS2015.

    Please help me out. 
    Wednesday, November 6, 2019 10:25 PM
  • Hi Johann,

    Did you test the suggest code by Chao in JS?If so, please share it.

    Regards
    Wednesday, November 6, 2019 10:27 PM