/// <summary> /// Find references and scatter files defined for the given assembly. /// </summary> /// <param name="reference">The reference to the parent assembly.</param> /// <param name="newEntries">New references are added to this list.</param> /// <param name="removeEntries">Entries that should be removed from the list.</param> private void FindDependenciesAndScatterFiles ( Reference reference, ArrayList newEntries ) { // Before checking for dependencies check to see if the reference itself exists. // Even though to get to this point the reference must be resolved // the reference may not exist on disk if the reference is a project to project reference. if (!_fileExists(reference.FullPath)) { reference.AddError ( new DependencyResolutionException(ResourceUtilities.FormatResourceString("General.ExpectedFileMissing", reference.FullPath), null) ); return; } try { IEnumerable<UnifiedAssemblyName> unifiedDependencies = null; string[] scatterFiles = null; GetUnifiedAssemblyMetadata(reference, out unifiedDependencies, out scatterFiles); reference.AttachScatterFiles(scatterFiles); // If no dependencies then fall out. if (unifiedDependencies == null) { return; } foreach (UnifiedAssemblyName unifiedDependency in unifiedDependencies) { // Now, see if it has already been found. Reference existingReference = GetReference(unifiedDependency.PostUnified); if (existingReference == null) { // This is valid reference. Reference newReference = new Reference(_isWinMDFile, _fileExists, _getRuntimeVersion); newReference.MakeDependentAssemblyReference(reference); if (unifiedDependency.IsUnified) { newReference.AddPreUnificationVersion(reference.FullPath, unifiedDependency.PreUnified.Version, unifiedDependency.UnificationReason); } foreach (AssemblyNameExtension remappedFromName in unifiedDependency.PreUnified.RemappedFromEnumerator) { newReference.AddRemapping(remappedFromName, unifiedDependency.PreUnified.CloneImmutable()); } newReference.IsPrerequisite = unifiedDependency.IsPrerequisite; DictionaryEntry newEntry = new DictionaryEntry(unifiedDependency.PostUnified, newReference); newEntries.Add(newEntry); } else { // If it already existed then just append the source items. if (existingReference == reference) { // This means the assembly depends on itself. This seems to be legal so we allow allow it. // I don't think this rises to the level of a warning for the user because fusion handles // this case gracefully. } else { // Now, add new information to the reference. existingReference.AddSourceItems(reference.GetSourceItems()); existingReference.AddDependee(reference); if (unifiedDependency.IsUnified) { existingReference.AddPreUnificationVersion(reference.FullPath, unifiedDependency.PreUnified.Version, unifiedDependency.UnificationReason); } existingReference.IsPrerequisite = unifiedDependency.IsPrerequisite; } foreach (AssemblyNameExtension remappedFromName in unifiedDependency.PreUnified.RemappedFromEnumerator) { existingReference.AddRemapping(remappedFromName, unifiedDependency.PreUnified.CloneImmutable()); } } } } catch (FileNotFoundException e) // Why isn't this covered in NotExpectedException? { reference.AddError(new DependencyResolutionException(e.Message, e)); } catch (FileLoadException e) { // Managed assembly was found but could not be loaded. reference.AddError(new DependencyResolutionException(e.Message, e)); } catch (BadImageFormatException e) { reference.AddError(new DependencyResolutionException(e.Message, e)); } catch (System.Runtime.InteropServices.COMException e) { reference.AddError(new DependencyResolutionException(e.Message, e)); } catch (Exception e) // Catching Exception, but rethrowing unless it's an IO related exception. { if (ExceptionHandling.NotExpectedException(e)) throw; reference.AddError(new DependencyResolutionException(e.Message, e)); } }
private void FindDependenciesAndScatterFiles(Reference reference, ArrayList newEntries) { try { IEnumerable<UnifiedAssemblyName> unifiedDependencies = null; string[] scatterFiles = null; this.GetUnifiedAssemblyMetadata(reference, out unifiedDependencies, out scatterFiles); reference.AttachScatterFiles(scatterFiles); if (unifiedDependencies != null) { foreach (UnifiedAssemblyName name in unifiedDependencies) { Reference reference2 = this.GetReference(name.PostUnified); if (reference2 == null) { Reference reference3 = new Reference(); reference3.MakeDependentAssemblyReference(reference); if (name.IsUnified) { reference3.AddPreUnificationVersion(reference.FullPath, name.PreUnified.Version, name.UnificationReason); } reference3.IsPrerequisite = name.IsPrerequisite; DictionaryEntry entry = new DictionaryEntry(name.PostUnified, reference3); newEntries.Add(entry); } else if (reference2 != reference) { reference2.AddSourceItems(reference.GetSourceItems()); reference2.AddDependee(reference); if (name.IsUnified) { reference2.AddPreUnificationVersion(reference.FullPath, name.PreUnified.Version, name.UnificationReason); } reference2.IsPrerequisite = name.IsPrerequisite; } } } } catch (FileNotFoundException exception) { reference.AddError(new DependencyResolutionException(exception.Message, exception)); } catch (FileLoadException exception2) { reference.AddError(new DependencyResolutionException(exception2.Message, exception2)); } catch (BadImageFormatException exception3) { reference.AddError(new DependencyResolutionException(exception3.Message, exception3)); } catch (COMException exception4) { reference.AddError(new DependencyResolutionException(exception4.Message, exception4)); } catch (Exception exception5) { if (Microsoft.Build.Shared.ExceptionHandling.NotExpectedException(exception5)) { throw; } reference.AddError(new DependencyResolutionException(exception5.Message, exception5)); } }