Is there a way to specify assembly references based on build configuration in Visual Studio?

后端 未结 2 1171
孤城傲影
孤城傲影 2020-12-07 18:51

I have a project that adds some extensibility to another application through their API. However, I want to be able to use the same project for multiple versions of their app

2条回答
  •  日久生厌
    2020-12-07 19:25

    There is a way to do this, but you will have to hand edit your project files. The project files can have a Condition attribute applied to them in many of the elements, including the one for references.

    You can add these to your references to specify when the reference should be used:

    
    
    
    
    
    
    

    You then define several build configurations (V1, V2, V3) and each reference will be included only in the relevant chosen build configuration.

    Combine this with conditional compilation symbols and #if statements in your code and you should be able to do what you want.

    A thing to be careful of if you do this is that it is easy to have Visual Studio remove the conditional attributes from the project file.

提交回复
热议问题