How to modify the csdef defined in a cspkg


To deploy to different azure environments I modify the csdef as part of the compilation step to change the host headers. Doing so requires building the cspkg once for each environment instead of being able to reuse the cspkg and specify different configs for deployment.

I would like to instead modify the csdef file of a cspkg after it has been created, without recompiling. Is that possible, and if so how?


I’ve done something similar to what you’re after to differentiate between test and live environments. First of all you need to create a new .csdef file that you want to use for your alternate settings. This needs to be the complete file as we’re just going to swap it out with the original one. Now we need to add this to the cloud project. Right click on the cloud project and select unload project. Right click on it again and select Edit [Name of project]. There’s a section that looks a bit like this:

Add a new ServiceDefinition item that points to your newly created file. Now find the following line:

Then add this code block, editing the TargeProfile check to be the build configuration you’re wanting to use for your alternate and ensuring that it points to your new .csdef file

To go back to normal, right click on the project and select Reload Project. Now when you build your project, depending on which configuration you use, it will use different .csdef files. It’s worth noting that the settings editor in is not aware of your second .csdef file so if you add any new settings through the GUI you will need to add them manually to this alternate version.


How to modify the csdef defined in a cspkg by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply