Friday, July 13, 2007

Could not find file InstallState

I created a Windows Service which needed installed onto the machine before I could test its functionality. I added a setup project (File > Add > New Project) and added the Setup Project under "Other Project Types". Everything built fine and I was ready to go until I started receiving the 'Could not find file...InstallState' when I tried to actually install the service. It took a half a day to figure out the problem, here is what I found. When you initially set up the project and go into Custom Actions to add primary output the project looks like this:

As you'll notice, there are too many primary active outputs. Delete all four from the left side under Install, Commit, Rollback, and Uninstall. If there are two under your setup file in Solution exporer (see highlights), then delete one or you will receive a some removed file error. The best way to do it is delete both and then right click the setup project (in solution explorer) go to Add > Project Output and set the service as primary output. You should then only have one listing under your setup project and none listed in the Custom Action section. Once your solution looks like the below, build and install.

2 comments:

Paul said...

It's 1am and I've been fighting with that error for an hour or so. I'd found plenty of other plausible explanations but nothing sorted it until I read your post!

Thanks for taking the time to write it up!

Paul.

Anonymous said...

Thank you..You saved my time..:)