Using Visual Studio project properties effectively for multiple projects and configurations

后端 未结 6 1266
清酒与你
清酒与你 2020-12-02 03:47

I have always used Visual Studios built in GUI support for configuring my projects, often using property sheets so that several projects will use a common set.

One o

6条回答
  •  执念已碎
    2020-12-02 04:31

    I had same pain for the product of my company (200+ projects) before. The way I solved it is to build a nice hierarchy of the property sheets.

    The projects inherits the property sheet by its output type, say x64.Debug.Dynamic.Library.vsprops. This vsprops file simply inherits other property sheets using the InheritedPropertySheets attribute

    
    

    You can also use variables (i.e. UserMacro, whose value can be absolute or even environment variables) in property sheets to customize a lot of things based on your need. For example, defining a BIN variable in Debug.vsprops

    
    

    then when you set the output name in the series of vsprops, say, Output.x64.Library.vsprops

    
    

    The $(BIN) variable will be expanded to what's been set (in this case, Debug). Use this technique you can easily construct a nice hierarchy of property sheets to meet your demand.

    Now there's one more thing you might want to do: build your own project templates that uses your property sheet set. The real difficult part is to enforce proper usage of the templates and property sheets. My personal experience is that even if everything is setup, somebody will still forget to use the template to create new projects ...

提交回复
热议问题