4- Build Configurations
0 (0 Likes / 0 Dislikes)
ok, imagine we want to build a configuration for a testing or staging environement
we may use a different mail servers, or mail message box and so on
so, from the toolbar from this dropdown list, select configuration manager
and then in this dropdown list use release build and use debug only when you are on development server
ok, now that we have a new build configuration. If you go to solution explorer and right click web.config
we will see a new item here
so we have web.debug, web.Release and now we have web.testing
so as an example, we can get this connection string here and put it out of the comments and this way we can overwrite the connection string to our database
so here we change the name of the connection string to default connection
because in our parents web.config
here is the parent
this is the name we use for our connection string
now back here, you see here
we have a different connection string,
so datasource=releaseSQLServer
we when we delpoy our application
staging or production use release build and use debug only when you are on development server
ok, now that we have a new build configuration. If you go to solution explorer and right click web.config
we will see a new item here, Add Config Transform, see what happens, we have a new config file
so we have web.debug, web.Release and now we have web.testing
so as an example, we can get this connection string here and put it out of the comments and this way we can overwrite the connection string to our database
so here we change the name of the connection string to default connection
because in our parents web.config
here is the parent
this is the name we use for our connection string
now back here, you see here
we have a different connection string,
so datasource=releaseSQLServer
we when we deploy our application
this configuration will transform our parents web.config
so now we can add any other setting that is specific to our setting environment,
now let me show you demo
so I am gonna save this file
remember the connection string is pointing to release SQL server
now, in solution explorer, I am going to the publish wizard again
profile tab, look, first of all, you have an existing profile
now I am gonna create a new one
testing, change the publish method to file system
and location to testing
now in the setting in the configuration we have a new item
and now let's deploy
I am gonna bring up the deployment folder
I am gonna bring this web.config into VS
here the default connection and it is pointing to releaseSQLServer
so this is how build configuration works
And finally before we finish this lecture
in solution explorer
if you open property
under publish profile you see we have 2 different profile
so imagine, this is for our production deployment
and this is for deploying to our testing environment
so both this file are just html
so here include the setting for each deployment environment
and when you check all this to your source control
all these publish profile are available for all developers in the team
so next time someone wants to deploy, they just go to the publish wizard
and select the right profile and then do the deployment
next I am going to talk about custom application setting