Windows Service Deployment

T

tshad

I have a Windows Service that I am deploying by setting a Deployment project
in my solution.

The problem I am having is with the app.config file. This where we store
our connection string and folder locations.

My development app.config is different from my clients.

When I send him an msi file, I have to either add the clients app.config
file into my project in 2 locations (as I am running as an exe as well as a
Service - which calls the code from the exe project) or send him the
app.config and have him replace it.

Is there a way to tell the deployment project to include a different
app.config file than is currently in the project.

Can you set up multiple build type (personalities) to run for testing?

Thanks,

Tom
 
P

Peter Ritchie [C# MVP]

Generally what I do is add an app.config to the application (so the setup can
see and deploy it). Then, I add several other application configurations,
one for each scenario. For example, I'll have the main app.config,
dev.config and release.config.

Then, for each configuration I have a pre-build event that copies the
appropriate config on top of app.config. I then only edit only dev.config or
release.config. This means the appropriate app.config exists in the bin
directory, plus it means when I build the setup the contents of the
release.config is used.
 
I

Ignacio Machin ( .NET/ C# MVP )

I have a Windows Service that I am deploying by setting a Deployment project
in my solution.

The problem I am having is with the app.config file.  This where we store
our connection string and folder locations.

My development app.config is different from my clients.

When I send him an msi file, I have to either add the clients app.config
file into my project in 2 locations (as I am running as an exe as well as a
Service - which calls the code from the exe project) or send him the
app.config and have him replace it.

Is there a way to tell the deployment project to include a different
app.config file than is currently in the project.

Can you set up multiple build type (personalities) to run for testing?

Thanks,

Tom

Hi,

Not that I know of. Of course you can change it in your project just
before generating the MSI :)
Now, if each client has a different config file, then you have a
similar problem.
What if you include another program that simply edit the config file
in a user friendly way?
 
T

tshad

Peter Ritchie said:
Generally what I do is add an app.config to the application (so the setup
can
see and deploy it). Then, I add several other application
configurations,
one for each scenario. For example, I'll have the main app.config,
dev.config and release.config.

Then, for each configuration I have a pre-build event that copies the
appropriate config on top of app.config. I then only edit only dev.config
or
release.config. This means the appropriate app.config exists in the bin
directory, plus it means when I build the setup the contents of the
release.config is used.
So do you have the 3 config files outside of the solution folders and then
copy (and rename them - ie "copy dev.config app.config")?

How do you do the pre-build event?

Thanks,

Tom
 
P

Peter Bromberg [C# MVP]

Right-click project node in Solution explorer, then properties, and choose
the Build Events property sheet. You can enter either / or a prebuild and
postbuild batch file there.
--Peter
tshad said:
Peter Ritchie said:
Generally what I do is add an app.config to the application (so the setup
can
see and deploy it). Then, I add several other application
configurations,
one for each scenario. For example, I'll have the main app.config,
dev.config and release.config.

Then, for each configuration I have a pre-build event that copies the
appropriate config on top of app.config. I then only edit only
dev.config or
release.config. This means the appropriate app.config exists in the bin
directory, plus it means when I build the setup the contents of the
release.config is used.
So do you have the 3 config files outside of the solution folders and then
copy (and rename them - ie "copy dev.config app.config")?

How do you do the pre-build event?

Thanks,

Tom
 
P

Peter Ritchie [C# MVP]

The configs would still be in the solution so they can be version controlled,
etc.

You can add a pre-build event in the projects properties (right click the
project in the solution explorer and select Properties). In the project
Properties, select the Build Events tab. Enter any commands you want
executed before the build is executed in the "Pre-build event command line"
text box.

If you're dealing with version control, you'll want to add commands to
ensure app.config is not write-protected before copying (or during copy with
XCOPY /R).

--
Browse http://connect.microsoft.com/VisualStudio/feedback/ and vote.
http://www.peterRitchie.com/blog/
Microsoft MVP, Visual Developer - Visual C#


tshad said:
Peter Ritchie said:
Generally what I do is add an app.config to the application (so the setup
can
see and deploy it). Then, I add several other application
configurations,
one for each scenario. For example, I'll have the main app.config,
dev.config and release.config.

Then, for each configuration I have a pre-build event that copies the
appropriate config on top of app.config. I then only edit only dev.config
or
release.config. This means the appropriate app.config exists in the bin
directory, plus it means when I build the setup the contents of the
release.config is used.
So do you have the 3 config files outside of the solution folders and then
copy (and rename them - ie "copy dev.config app.config")?

How do you do the pre-build event?

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top