Search code examples
visual-studiomsbuildvisual-studio-extensions

Best way to automate editing project file


Actually editing *.cproj files manually, some code in the project template deletes my edits. So i'm forced to edit the file constantly before i build.. What way would you take to automate this:

  • is it possible to write a vs extension to have a custom tab in project options that reacts to checkboxes modifying project file for me
  • any other way?..

Thanks


Solution

  • automate editing project file

    Something like a button or menu in VS, click it then some content which you used to add manually will be added into .proj file automatically? If I misunderstand, feel free to correct me:)

    What way would you take to automate this:

    Hard to say, but in short, I think it depends on whether you're experienced in extension development.

    Since if you combine the functions into a extension. Every time when you want to add some custom changes to them, all you need to do is just click a button in VS or select a checkbox. It sounds good but the development of extension may take you some time and you may encounter some issues during the development.The journey could be challenging but instersting!

    is it possible to write a vs extension to have a custom tab in project options that reacts to checkboxes modifying project file for me

    It's absolutely possible.Just take a look at this extension,it provides a function which edit project in VS.

    Not sure the details how your ideal extension is. But I think you may get some help below:

    1.Extend menus and commands if you want to start the function by menu command.

    Also, you may get some help from this issue which gives the suggestion about how to put function button under Add-node in solution explorer.

    2.Assuming you have function code which adds content into a .xxproj file.(This part is about developing, add nodes to xml-based proj file?).Then add that code into a event handle which will be called when clicking the button or menu.(Something like this)

    So I think it's possible but may take some time. And it will be the most automatic way but it takes some time to develop. Anyway, hope it helps and good luck with you.