开发者

Best configuration strategy for testing/deploying in different environments

开发者 https://www.devze.com 2023-04-12 14:07 出处:网络
I am creating a web service that uses Fluent NHibernate and I am developing across several Machines that of course have different connection strings.I am wondering how do I go about configuring the te

I am creating a web service that uses Fluent NHibernate and I am developing across several Machines that of course have different connection strings. I am wondering how do I go about configuring the test/deployed service across the different environments besides using configuration files.

For example on each machine I use a different server and for tests I use a test database. I want to be able to have it so that when I check o开发者_Python百科ut on each machine I don't have to modify a file checked in (the .config) to pick up connection string. For example:

public interface IDataConfig
{
    public Server { get; set; }
    public Database { get; set; }
    public Username { get; set; }
    public Password { get; set; }

    public void Initialize();
    public string GetConnectionString();
    //...Other Fluent-hibernate specific configuration/session methods 
}

public ServiceDataConfig : IDataConfig
{
    //....
}

public TestDataConfig : IDataConfig
{
    //....
}

I wonder is the best thing that there be a configuration file that reads in the connectionstring and any other configuration so that the concrete classes pick it up or should I manually configure them after I check out from the repository.


You want to look at Web Config Transforms where you can have multiple config files for different deployment scenarios. That way you can have them all in TFS without any problems, just check them in and out without having to worry about changing the settings each time you need to deploy.

http://blogs.msdn.com/b/webdevtools/archive/2009/05/04/web-deployment-web-config-transformation.aspx

Best configuration strategy for testing/deploying in different environments

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号