There is a long discussion thread about this on MSDN. It seems like there are many possible causes. The discussion includes a few links for this problem from Microsoft. Here is a hotfix for VS2005 and here is a workaround for VS2010.
I had the similar problem and found a fix in this very long and old discussion on MSDN.
As the user 'Jeff Hunsaker' on Thursday, August 26, 2010 5:51 PM answered (direct link not possible):
I just encountered this when upgrading Visual Studio 2008 Deployment Projects to VS 2010. Hans' (above) solution worked for me.
Edit the .vdproj file in Notepad.
Search for "SourcePath" = "8:
For each assembly/dll, provide the full path
Save file
Within my .vdproj file, I had several entries simply referencing the assembly:
"SourcePath" = "8:MyAssembly.DLL"
Even though Visual Studio [somehow] knew the file location, I received the "Unable to update the dependencies of the project" error until I provided the full path:
I've had the same issue, but none of the mentioned resolutions seemed to work for me. Rebuilding the setup project would work, but it is a pain, since we include the project outputs of 30+ projects.
The thing I found to work is a very similar approach to what @Marc did.
I noted which dependencies were reported by Visual Studio as errors
Edit the .vdproj file in Notepad++
Search for the .dll that is giving issues. You will see a "ScatterAssemblies" section. If it is empty, delete the whole dll reference
Save file
In all cases I had multiple references to the same dll (not sure how this happened)
I also got the same "Two or more objects have the same target location ('[targetdir]\MyAssembly.dll')" warning that @Marc got ... but the setup project compiles and runs fine.
This solved the same problem for me:
I added the assemblies that were mentioned in the error message to the GAC. When I recompiled the project the dll's appeared under "Detected Dependencies" in the Solution Explorer and I got the same error. Then I excluded the dll's (right-click and select Exclude) and the project finally compiled ok.
1) Removing one of the problem DLLs from the setup project, and then re-adding just that one resolved the problem for me. This worked even when there were many DLLs with the problem. Removing and adding just one of them triggered VS2010 to fix them all up somehow.
2) Rebuild the solution, then try updating the dependencies again. The rebuild helps visual studio discover what the dependencies are, because it may be struggling to find the dependencies with nothing built.
3) Restart Visual Studio
The VS2010 hotfix linked above didn't work for me. Sometimes restarting VS2010 will fix the problem and when that doesn't work, doing the above works.
The problem may be caused by orphaned files in the "Deployable" -> "File" section of the .vdproj file. You can verify this by removing all files from the setup project in Visual Studio (make a backup first). If you open the .vdproj file with a text editor and still see entries in the "File" section you have this problem. You can note the keys of these files and remove them from the original .vdproj file and it should work again.
Alternatively compile this quick fix program (tested only with Visual Studio 2010):
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
class Program {
static void Main(string[] args) {
try {
if (args.Length == 0) {
Console.WriteLine("FixVDProj <path to .vdproj file>");
return;
}
if (!File.Exists(args[0])) {
throw new Exception("File " + args[0] + " does not exist!");
}
string[] strarSource = File.ReadAllLines(args[0]);
List<string> listDest = new List<string>();
List<string> listKnownKeys = new List<string>();
int iSection = 0;
bool bAccept = true;
bool bNeedFix = false;
foreach (string strLine in strarSource) {
switch (iSection) {
case 0:
if (strLine.Trim() == "\"DeployProject\"") {
listDest.Add(strLine);
iSection++;
} else {
throw new Exception("\"DeployProject\" not found");
}
break;
case 1:
if (strLine.Trim() == "\"Hierarchy\"") {
iSection++;
}
listDest.Add(strLine);
break;
case 2:
if (strLine.Trim().StartsWith("\"MsmKey\" = ")) {
int p = strLine.IndexOf('=');
string strMsm = strLine.Substring(p + 1).Trim();
if (strMsm.StartsWith("\"8:") && strMsm.EndsWith("\"")) {
listKnownKeys.Add(strMsm.Substring(3, strMsm.Length - 4));
} else {
throw new Exception("Invalid MsmKey " + strMsm);
}
} else if (strLine.Trim() == "\"Deployable\"") {
iSection++;
}
listDest.Add(strLine);
break;
case 3:
if (strLine.Trim() == "\"File\"") {
iSection++;
}
listDest.Add(strLine);
break;
case 4:
if (strLine.Trim() == "{") {
iSection++;
}
listDest.Add(strLine);
break;
case 5:
if (strLine.Trim() == "}") {
listDest.Add(strLine);
iSection = -1; // finished
} else if (strLine.Trim().StartsWith("\"") && strLine.Contains(':')) {
int p = strLine.IndexOf(':');
string strKey = strLine.Substring(p + 1, strLine.Length - p - 2);
if (listKnownKeys.Contains(strKey)) {
Console.WriteLine("Accepted key " + strKey);
bAccept = true;
listDest.Add(strLine);
} else {
Console.WriteLine("Invalid key " + strKey + " removed");
bAccept = false;
bNeedFix = true;
}
} else if (strLine.Trim() == "{") {
if (bAccept) {
listDest.Add(strLine);
}
iSection++;
} else {
listDest.Add(strLine);
}
break;
case 6:
case 7:
case 8:
case 9:
if (strLine.Trim() == "{") {
iSection++;
} else if (strLine.Trim() == "}") {
iSection--;
}
if (bAccept) {
listDest.Add(strLine);
}
break;
case 10:
throw new Exception("File structure depth exceeded!");
default:
listDest.Add(strLine);
break;
}
}
if (bNeedFix) {
File.Copy(args[0], args[0] + ".bak", true);
File.WriteAllLines(args[0], listDest);
Console.WriteLine("File " + args[0] + " has been fixed!");
} else {
Console.WriteLine("File " + args[0] + " did not need fix!");
}
} catch (Exception e) {
Console.WriteLine(e.ToString());
}
}
}
Restarting VS2010 didn't work for me but I managed to get everything working by doing a 'Clean Solution', then a 'Build Solution'. Trying 'Rebuild Solution' after the clean didn't work however. Then I could run the Solution with F5 as normal.
When I get this error I find my VS2010 deployment project (.vdproj) is 'corrupted'. Specifically, items in the FILE section of the VDPROJ file have GUID's that are missing from the HIERARCHY section of the VDPROJ file. This is described in detail below.
1) VS2010 deployment projects include the following sections:
"Hierarchy"
{
}
"Deployable"
{
"File"
{
}
}
2) The HIERARCHY section contains GUIDs for each item (e.g. file) added to the deployment project. In addition, each file added to the project appears as an item under the DEPLOYABLE > FILE section. The following example shows a normal configuration for the file msimg32.dll. Note the matching GUID (i.e. _1C15DB39774F7E79C84F1CC87ECFD60A) in the HIERARCHY and FILE sections.
3) My VS2010 deployment projects can be corrupted in two ways:
a) An item in the FILE section is duplicated and the duplicated item is given a GUID which does not appear in the HIERARCHY section.
b) The GUID associated with an item in the FILE section has been removed from the HIERARCHY section (i.e. the item in the FILE section is orphaned).
3a) Example of first problem - duplicated item in FILE section:
In this example, the file msimg32.dll has two entries in the FILE section. The first (i.e. correct) entry has a matching GUID (i.e. _1C15DB39774F7E79C84F1CC87ECFD60A) in the HIERARCHY section, but the GUID for the second (i.e. error) entry (i.e. 2DDC4FA12BFD46DEAED0053D23331348) does not appear in the HIERARCHY section.
3b) Example of second problem - orphaned item in the FILE section:
In this example, the file msimg32.dll has an entry in the FILE section. But the GUID associated with this entry (i.e. A515046ADA6244F2A260E67625E4398F) does not have a matching entry in (i.e. it is missing from) the HIERARCHY section.