If your deploy a new version of your app and your users see “Cannot Start Application” when updating:
There could be many reasons, this quick post provides a few places to look to find what may be causing the File Already Exists problem.
Click on ‘Details’…and if your error looks something like this…then this most may help:
ERROR SUMMARY Below is a summary of the errors, details of these errors are listed later in the log. * Activation of ...\Start Menu\Programs\MyApp\MyApp\MyApp.appref-ms| resulted in exception. Following failure messages were detected: + The file '...\Local Settings\Temp\Deployment\GOYP6PP3.TRR\61YND8Y2.Q2A\NaughtyFile.dll' already exists.
Where to look
Open up your ..\Application Files\MyApp184.108.40.206 directory (where 220.127.116.11 is the current build number)
Find and open the .manifest file, should be called MyApp.manifest.
Search for NaughtFile.dll (in the error above, NaughtyFile.dll was the name of the file that already exists), if your problem is the same as mine then you should find two references to this file in the manifest. In my case I had one reference which was a dependentAssembly and another which was a file.
Now, the project you are publishing may not have a direct reference to a dll and yet it still appears in the list of dependentAssemblies because a project it references does directly reference the dll. The easiest way to check this list is to go to the project properties, Publish Tab and open Application Files…
From there you see the list of files that are included, but I’ve noticed sometimes the list is not 100% truthful, if weird stuff is happening, open your project file in Notepad and closely examine the list of included and excluded files.
Note that you can only exclude a file in this list if the project has a direct reference to the file (this may not be true, but I just tried it and it didn’t exclude and I don’t have time for further investigation).
So our trouble, our extra ‘file’ reference came from an extension to msBuild that we have to explicitly include certain files (needed if you need the dll but cannot add a reference for example), that looks a little like this….
<ItemGroup> <AdditionalPublishFile Include="..\..\NaughtyFileLocation\*"> <Visible>False</Visible> </AdditionalPublishFile> ....
By changing the explicit inclusion to ‘not’ include that specific file (we needed other files in that directory), our problem went away. The key is ensuring that your manifest only has one entry for each file that is included…the trick is figuring out why there are multiple entries!