How to add config transformations for a custom config file in Visual Studio?

后端 未结 5 2027
日久生厌
日久生厌 2020-12-03 06:58

The project I am working on involves reading a lot of service endpoints (url) from a config file. Since the list would be quite large I decided to keep them in a custom conf

5条回答
  •  無奈伤痛
    2020-12-03 07:46

    I have been using SlowCheetah but I found something that I think is more elegant. Just telling to the build to generate the .config depending on the build configuration.

    Having a app.Release.config in your project (or many more depending on you deployment needs) you just need to edit the project file (the .csproj one if you program in C#). Find the end of it, between the last and and add:

      
      
      
      
        
          $(OutputType)
          dll
          dll
          exe
        
        
      
    
    

    Save and reload from VisualStudio. Compile in Release mode and check the bin/Release folder on your .config file the transformation is done.

    This example applies to Exe and Dll files and any VisualStudio version because includes this post help

提交回复
热议问题