在提交 Subversion 之后,“无法更新项目的依赖项”

我有一个设置项目。NET.当我将项目和其他项目保存到 subversion 时,安装项目不再编译。我得到错误“无法更新项目的依赖项”

52795 次浏览

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.

  1. Edit the .vdproj file in Notepad.
  2. Search for "SourcePath" = "8:
  3. For each assembly/dll, provide the full path
  4. 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:

"SourcePath" = "8:..\..\..\build\bin\MyCompany.MyAssembly.DLL"

Regards,

Jeff...

I noted which dependencies were reported by Visual Studio and wrote a script to fix them in case this is required.

Note that this now gives me a warning "Two or more objects have the same target location ('[targetdir]\MyAssembly.dll'). But I can live with that.

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.

  1. I noted which dependencies were reported by Visual Studio as errors
  2. Edit the .vdproj file in Notepad++
  3. Search for the .dll that is giving issues. You will see a "ScatterAssemblies" section. If it is empty, delete the whole dll reference
  4. Save file

In all cases I had multiple references to the same dll (not sure how this happened)

Example of correct reference:

"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_11EC89A306FFB83A269ACC2BF8D8462B"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:Some.OrOther.Lib, Version=1.601.4042.16978, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
"_11EC89A306FFB83A269ACC2BF8D8462B"
{
"Name" = "8:Some.OrOther.Lib.dll"
"Attributes" = "3:512"
}
}
"SourcePath" = "8:Some.OrOther.Lib.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_79891234C744498C83755DDEA682F0BF"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}

Example of incorrect reference:

"{9F6F8455-1EF1-4B85-886A-4223BCC8E7F7}:_11EC89A306FFB83A269ACC2BF8D8462B"
{
"AssemblyRegister" = "3:1"
"AssemblyIsInGAC" = "11:FALSE"
"AssemblyAsmDisplayName" = "8:Some.OrOther.Lib, Version=1.601.4042.16978, Culture=neutral, processorArchitecture=MSIL"
"ScatterAssemblies"
{
}
"SourcePath" = "8:Some.OrOther.Lib.dll"
"TargetName" = "8:"
"Tag" = "8:"
"Folder" = "8:_79891234C744498C83755DDEA682F0BF"
"Condition" = "8:"
"Transitive" = "11:FALSE"
"Vital" = "11:TRUE"
"ReadOnly" = "11:FALSE"
"Hidden" = "11:FALSE"
"System" = "11:FALSE"
"Permanent" = "11:FALSE"
"SharedLegacy" = "11:FALSE"
"PackageAs" = "3:1"
"Register" = "3:1"
"Exclude" = "11:FALSE"
"IsDependency" = "11:TRUE"
"IsolateTo" = "8:"
}

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.

Correct link for hot-fix for VS2010 is:

http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=30681

Works fine after installation

Closing VS2010 and then re-opening it has always worked for me :)

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.

Here are a couple of solutions that work:

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.

I managed to work around this issue by removing the installer project from the solution then adding the existing project back in again.

This can also happen when you are trying to debug and have selected the Release mode. Got me just now :(

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.

"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_1C15DB39774F7E79C84F1CC87ECFD60A"
"OwnerKey" = "8:_0C67A6B6004040DC93A0113E1100615D"
"MsmSig" = "8:_UNDEFINED"
}
}
"Deployable"
{
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1C15DB39774F7E79C84F1CC87ECFD60A"
{
"SourcePath" = "8:MSIMG32.dll"
"TargetName" = "8:MSIMG32.dll"
… more information ...
}
}
}

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.

"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_1C15DB39774F7E79C84F1CC87ECFD60A"
"OwnerKey" = "8:_0C67A6B6004040DC93A0113E1100615D"
"MsmSig" = "8:_UNDEFINED"
}
}
"Deployable"
{
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1C15DB39774F7E79C84F1CC87ECFD60A"
{
"SourcePath" = "8:MSIMG32.dll"
"TargetName" = "8:MSIMG32.dll"
… more information ...
}
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_2DDC4FA12BFD46DEAED0053D23331348"
{
"SourcePath" = "8:MSIMG32.dll"
"TargetName" = "8:MSIMG32.dll"
… more information ...
}
}
}

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.

"Hierarchy"
{
}
"Deployable"
{
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_A515046ADA6244F2A260E67625E4398F"
{
"SourcePath" = "8:MSIMG32.dll"
"TargetName" = "8:MSIMG32.dll"
… more information ...
}
}
}

4) Solution: For both problems illustrated above, the solution is to delete the orphaned item in the FILE section.

The following example shows how the FILE section in point 3a above would appear after the second entry for msimg32.dll has been deleted.

"Hierarchy"
{
"Entry"
{
"MsmKey" = "8:_1C15DB39774F7E79C84F1CC87ECFD60A"
"OwnerKey" = "8:_0C67A6B6004040DC93A0113E1100615D"
"MsmSig" = "8:_UNDEFINED"
}
}
"Deployable"
{
"File"
{
"{1FB2D0AE-D3B9-43D4-B9DD-F88EC61E35DE}:_1C15DB39774F7E79C84F1CC87ECFD60A"
{
"SourcePath" = "8:MSIMG32.dll"
"TargetName" = "8:MSIMG32.dll"
… more information ...
}
}
}

5) I found the corrupted entries in the VDPROJ only occurred for:

  • a) assembly files (i.e. DLL) from my C# projects and
  • b) detected dependencies from my C++ projects (e.g. version.dll, urlmon.dll)

I would like to add, that I get the same error when I edit the deployment project from my computer instead of the dedicated compiler computer.

The last time I got that error I needed to roll back the last changes, and re-do it from the dedicated compiler computer.