Add Config Transform in Visual Studio
This is a basic thing but I forget how to do it from time to time.
You may want to add a Config transform (i.e. Web.Something.Config
) to a project in one of these situations:
- A) You added a new project to a solution with a load of Configurations and you want a matching config in the new project
- B) You want to add a brand new Configuration to every project
The upshot is pretty much the same:
Step 1. Go into Configuration Manager
Open configuration manager by dropping down the config list (in the Standard toolbar) and selecting ‘Configuration Manager…’ (or, find the same option by right clicking your Solution in Solution Explorer)
If (A) this configuration already exists at Solution level then for each project, drop it down, hit ‘New…’, type the name, copy from nowhere, don’t tick ‘Create new solution configurations’. Go to Step 2.
If (B) this configuration is brand new and doesn’t exist for any project yet then use the top dropdown (‘Active solution configuration’) and pick ‘New…’, name it, copy from another config at your own disgression, and tick ‘Create new project configurations’, otherwise you’ll have to do them one-by-one as above! Congrats, you’re done.
Step 2. Add Config Transform on each project
If you need to backfill config transforms for new projects:
- Activate the config you want in the Standard toolbar
- Right click, in Solution Explorer, the project that needs the config transform,
- Click ‘Add Config Transform’ (pictured)
This option only appears if there is no config transform, for that config, in this project.
Job done, make web.