I am wondering what is the best way to properly create a Development and Production environment for my C# winforms project. The unfortunate thing is that there is no development environment. Rather, I must specify the publish path each time i wish to create either the Production or Development build. Also since each prod or dev build uses a different connection string I must then go into the code and change that as well.
EDIT Another thing i would like to add is the fact that the 'testers' so to speak will be running the program from a local .exe which will look at the source files and detect if an update needs to be made. The only reason i am mentioning this is because the testers will not be running the code in 'DEBUG' mode.
Any ideas?
Thanks in advance!
UPDATE
Whew, 2009 sure was a long time ago ;) I'm going to leave the original answer for posterity, but, as Eric J. already stated in an updated version of his post in 2012, Slowcheetah is a much more flexible approach to this problem as it let's you create multiple config file per configuration.
Original answer
I can't answer for the publish part as I'm not sure it can be done. However, for the connection string part, you could make a "Connection String Provider Class" which would return the development connection string if you are in development, or the production connection string if you are in production.
I don't know if you are using Debug and Release compilation mode in the configuration manager, but it could be possible to use that with a pre-compiler directive:
public class ConnectionStringProvider
{
public static string GetConnectionString()
{
#if (DEBUG)
return DevConnectionString;
#else
return ProdConnectionString;
#endif
}
}
If you are using the VS2005 Settings pane (in the project settings), you can set 2 connections strings in there and use that instead of a constant value. If you are using any of the .Net DataSource, you could be always using the DEV connection string to create your object.
Also, the connection string provider could use a Singleton pattern, but I'm not sure there would be a real benefit.