Windows service setup project doesn't copy ref

2019-08-05 19:47发布

问题:

I've just built a windows service and it runs like a dream in debug/release on my dev machine. I've created a setup project following steps in walkthroughs such as this blog post, this msdn walkthrough, and this generous answer to a rather lazy SO question.

My project installs fine on a target machine, but when I run it, the timer ticks but nothing happens. When investigating this I noticed that the installer doesn't seem to have copied over a couple of dlls with it that are referenced in my app. I can see them in my bin folder for the app, and I can see them listed in the dependencies array from the Primary output from MyProject (Active) node in my setup project. But they're not in the app's Program Files folder where the .exe is on the target machine.

Can anyone suggest some steps I can go through to ensure I'm doing this correctly?

回答1:

Turns out you need to explicitly add referenced files to the setup project (right-click on the setup project, and Add > File... and browse to/select the applicable files).

However, I'd still like to know:

  • How this may be automated, particularly when packages are present in the app using NuGet
  • Whether I missed a step that caused me to need to do it manually.
  • Whether I may have missed something, for example relating to Install/Commit/Rollback/Uninstall custom actions that are required in the setup project