How to handle multiple web.config conversions for different instances when working with multiple publishing goals?

I have an ASP.NET ASP.NET site where I manage multiple instances. Each instance uses its own database, but the code base is the same. To facilitate this, I have several build configurations with the appropriate web.config transformations, so when I publish it, it does not use my development database, but instead uses a specific database for this site instance.

The problem with this appeared today when I posted an update on one of the sites. I forgot to reconfigure the assembly, so my posting on site A used the web.config conversion for site B, and there was chaos and confusion.

Is it possible to indicate that a specific publication target will ONLY be used with a specific assembly configuration?

Or is there a better way to handle this situation than juggling assembly configurations?

+4
source share
3 answers

Perhaps you could find a solution in which you would not rely on the Publish dialog box of the web application, which requires you to make the right setting each time, but instead use an automatic command line solution (batch file, your own goal msbuild or a build server such as CStroliaDavis offered by [cruisecontrol, tfs, teamcity]).

You can simply call the target "package" from the command line that creates the package:

msbuild MyWebProject.csproj /t:Package /P:Configuration=Release;DeployIisAppPath="Default Web Site/Main/MyWebProject";PackageLocation="F:\MyWebProjectDeploy.zip" 

This also creates a * .cmd file, so you can deploy it as follows:

 F:\MyWebProjectDeploy.deploy.cmd /Y -allowUntrusted /M:http://webserver/MSDeployAgentService /U:Administrator /P:"Secret" 

You can add a custom * .msbuild file to your solution that performs these actions, or maybe the easiest way is to add a command to Tools โ†’ External Tools.

+1
source

One way to deal with such things, and I'm not sure if this is the best, but this is the way is to set certain configuration values โ€‹โ€‹at a higher level on the web.config or machine.config file, which is always on the machine in question.

Then just make sure your project files do not override these configuration values.

Here are some considerations if you do.

  • If you want the initial control of these values, it can be more difficult this way (it can be pro or con depending on your environment).
  • If other virtual sites are on the same machine and use the same configuration value, this can affect them all, and if several sites use the same configuration value, changing it to the source will change them all (again, maybe about or con depending).
  • If something is wrong with the meaning, it may be more difficult to determine where the problem is or what causes it.
  • Access to machine.config can be difficult in your organization or with your hosting provider depending on your access / security privileges, and it is not always possible to put web.config at a higher level than your application.

Obviously, itโ€™s good that you can have a different value configured on each computer, and until these values โ€‹โ€‹are also set in your web.config (which will probably lead to an error), you wonโ€™t have to worry about compiling different versions.

I believe that Visual Studio 2010 has a way to install different configuration files for different types of assemblies, but this is very similar to what you are already doing, so forgetting to build the right path can still lead to similar results.

You can try to configure continuous integration with something like TFS Build, if it is available to you, in which case what is created for prod can be configured to always work in a certain way and always extract from the correct build type.

Hope something helps here.

+3
source

With kwateeSDCM, you cannot just deploy applications and web applications, but you can also manage instance-by-instance settings or file overrides. I used it only with tomcat wars, but it is not tied to a language or platform, so I believe that it should be simple in order to configure it to work with ASP.NET.

+1
source

All Articles