internal void MakeDependentAssemblyReference(Reference sourceReference)
 {
     this.copyLocalState      = CopyLocalState.Undecided;
     this.isPrimary           = false;
     this.DependenciesFound   = false;
     this.wantSpecificVersion = true;
     this.AddSourceItems(sourceReference.GetSourceItems());
     this.AddDependee(sourceReference);
 }
Exemplo n.º 2
0
        internal void MakeDependentAssemblyReference(Reference sourceReference)
        {
            CopyLocal = CopyLocalState.Undecided;

            // This is a true dependency, so its not primary.
            IsPrimary = false;

            // This is an assembly file, so we'll need to find dependencies later.
            DependenciesFound = false;

            // Dependencies must always be specific version.
            WantSpecificVersion = true;

            // Add source items from the original item.
            AddSourceItems(sourceReference.GetSourceItems());

            // Add dependees
            AddDependee(sourceReference);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Set metadata on the items which will be output from RAR.
        /// </summary>
        private ITaskItem SetItemMetadata(ArrayList relatedItems, ArrayList satelliteItems, ArrayList serializationAssemblyItems, ArrayList scatterItems, string fusionName, Reference reference, AssemblyNameExtension assemblyName, FileExists fileExists)
        {
            // Set up the main item.
            ITaskItem referenceItem = new TaskItem();
            referenceItem.ItemSpec = reference.FullPath;
            referenceItem.SetMetadata(ItemMetadataNames.resolvedFrom, reference.ResolvedSearchPath);

            // Set the CopyLocal metadata.
            if (reference.IsCopyLocal)
            {
                referenceItem.SetMetadata(ItemMetadataNames.copyLocal, "true");
            }
            else
            {
                referenceItem.SetMetadata(ItemMetadataNames.copyLocal, "false");
            }

            // Set the FusionName metadata.
            referenceItem.SetMetadata(ItemMetadataNames.fusionName, fusionName);

            // Set the Redist name metadata.
            if (!String.IsNullOrEmpty(reference.RedistName))
            {
                referenceItem.SetMetadata(ItemMetadataNames.redist, reference.RedistName);
            }

            if (Reference.IsFrameworkFile(reference.FullPath, _frameworkPaths) || (_installedAssemblies != null && _installedAssemblies.FrameworkAssemblyEntryInRedist(assemblyName)))
            {
                if (!IsAssemblyRemovedFromDotNetFramework(assemblyName, reference.FullPath, _frameworkPaths, _installedAssemblies))
                {
                    referenceItem.SetMetadata(ItemMetadataNames.frameworkFile, "true");
                }
            }

            if (!String.IsNullOrEmpty(reference.ImageRuntime))
            {
                referenceItem.SetMetadata(ItemMetadataNames.imageRuntime, reference.ImageRuntime);
            }

            if (reference.IsWinMDFile)
            {
                referenceItem.SetMetadata(ItemMetadataNames.winMDFile, "true");

                // The ImplementationAssembly is only set if the implementation file exits on disk
                if (reference.ImplementationAssembly != null)
                {
                    if (VerifyArchitectureOfImplementationDll(reference.ImplementationAssembly, reference.FullPath))
                    {
                        referenceItem.SetMetadata(ItemMetadataNames.winmdImplmentationFile, Path.GetFileName(reference.ImplementationAssembly));

                        // Add the implementation item as a related file
                        ITaskItem item = new TaskItem(reference.ImplementationAssembly);
                        // Clone metadata.
                        referenceItem.CopyMetadataTo(item);
                        // Related files don't have a fusion name.
                        item.SetMetadata(ItemMetadataNames.fusionName, "");
                        RemoveNonForwardableMetadata(item);

                        // Add the related item.
                        relatedItems.Add(item);
                    }
                }

                if (reference.IsManagedWinMDFile)
                {
                    referenceItem.SetMetadata(ItemMetadataNames.winMDFileType, "Managed");
                }
                else
                {
                    referenceItem.SetMetadata(ItemMetadataNames.winMDFileType, "Native");
                }
            }

            // Set the IsRedistRoot metadata
            if (reference.IsRedistRoot == true)
            {
                referenceItem.SetMetadata(ItemMetadataNames.isRedistRoot, "true");
            }
            else if (reference.IsRedistRoot == false)
            {
                referenceItem.SetMetadata(ItemMetadataNames.isRedistRoot, "false");
            }
            else
            {
                // This happens when the redist root is "null". This means there
                // was no IsRedistRoot flag in the Redist XML (or there was no 
                // redist XML at all for this item).
            }

            // If there was a primary source item, then forward metadata from it.
            // It's important that the metadata from the primary source item
            // win over the same metadata from other source items, so that's
            // why we put this first.  (CopyMetadataTo will never override an 
            // already existing metadata.)  For example, if this reference actually
            // came directly from an item declared in the project file, we'd
            // want to use the metadata from it, not some other random item in
            // the project file that happened to have this reference as a dependency.
            if (reference.PrimarySourceItem != null)
            {
                reference.PrimarySourceItem.CopyMetadataTo(referenceItem);
            }
            else
            {
                bool hasImplementationFile = referenceItem.GetMetadata(ItemMetadataNames.winmdImplmentationFile).Length > 0;
                bool hasImageRuntime = referenceItem.GetMetadata(ItemMetadataNames.imageRuntime).Length > 0;
                bool hasWinMDFile = referenceItem.GetMetadata(ItemMetadataNames.winMDFile).Length > 0;

                // If there were non-primary source items, then forward metadata from them.
                ICollection sourceItems = reference.GetSourceItems();
                foreach (ITaskItem sourceItem in sourceItems)
                {
                    sourceItem.CopyMetadataTo(referenceItem);
                }

                // If the item originally did not have the implementation file metadata then we do not want to get it from the set of primary source items
                // since the implementation file is something specific to the source item and not supposed to be propigated.
                if (!hasImplementationFile)
                {
                    referenceItem.RemoveMetadata(ItemMetadataNames.winmdImplmentationFile);
                }

                // If the item originally did not have the ImageRuntime metadata then we do not want to get it from the set of primary source items
                // since the ImageRuntime is something specific to the source item and not supposed to be propigated.
                if (!hasImageRuntime)
                {
                    referenceItem.RemoveMetadata(ItemMetadataNames.imageRuntime);
                }

                // If the item originally did not have the WinMDFile metadata then we do not want to get it from the set of primary source items
                // since the WinMDFile is something specific to the source item and not supposed to be propigated
                if (!hasWinMDFile)
                {
                    referenceItem.RemoveMetadata(ItemMetadataNames.winMDFile);
                }
            }

            if (reference.ReferenceVersion != null)
            {
                referenceItem.SetMetadata(ItemMetadataNames.version, reference.ReferenceVersion.ToString());
            }
            else
            {
                referenceItem.SetMetadata(ItemMetadataNames.version, String.Empty);
            }

            // Now clone all properties onto the related files.
            foreach (string relatedFileExtension in reference.GetRelatedFileExtensions())
            {
                ITaskItem item = new TaskItem(reference.FullPathWithoutExtension + relatedFileExtension);
                // Clone metadata.
                referenceItem.CopyMetadataTo(item);
                // Related files don't have a fusion name.
                item.SetMetadata(ItemMetadataNames.fusionName, "");
                RemoveNonForwardableMetadata(item);

                // Add the related item.
                relatedItems.Add(item);
            }

            // Set up the satellites.
            foreach (string satelliteFile in reference.GetSatelliteFiles())
            {
                ITaskItem item = new TaskItem(Path.Combine(reference.DirectoryName, satelliteFile));
                // Clone metadata.
                referenceItem.CopyMetadataTo(item);
                // Set the destination directory.
                item.SetMetadata(ItemMetadataNames.destinationSubDirectory, FileUtilities.EnsureTrailingSlash(Path.GetDirectoryName(satelliteFile)));
                // Satellite files don't have a fusion name.
                item.SetMetadata(ItemMetadataNames.fusionName, "");
                RemoveNonForwardableMetadata(item);

                // Add the satellite item.
                satelliteItems.Add(item);
            }

            // Set up the serialization assemblies
            foreach (string serializationAssemblyFile in reference.GetSerializationAssemblyFiles())
            {
                ITaskItem item = new TaskItem(Path.Combine(reference.DirectoryName, serializationAssemblyFile));
                // Clone metadata.
                referenceItem.CopyMetadataTo(item);
                // serialization assemblies files don't have a fusion name.
                item.SetMetadata(ItemMetadataNames.fusionName, "");
                RemoveNonForwardableMetadata(item);

                // Add the serialization assembly item.
                serializationAssemblyItems.Add(item);
            }

            // Set up the scatter files.
            foreach (string scatterFile in reference.GetScatterFiles())
            {
                ITaskItem item = new TaskItem(Path.Combine(reference.DirectoryName, scatterFile));
                // Clone metadata.
                referenceItem.CopyMetadataTo(item);
                // We don't have a fusion name for scatter files.
                item.SetMetadata(ItemMetadataNames.fusionName, "");
                RemoveNonForwardableMetadata(item);

                // Add the satellite item.
                scatterItems.Add(item);
            }

            // As long as the item has not come from somewhere else say it came from rar (p2p's can come from somewhere else).
            if (referenceItem.GetMetadata(ItemMetadataNames.msbuildReferenceSourceTarget).Length == 0)
            {
                referenceItem.SetMetadata(ItemMetadataNames.msbuildReferenceSourceTarget, "ResolveAssemblyReference");
            }

            if (referenceItem.GetMetadata(ItemMetadataNames.msbuildReferenceSourceTarget).Equals("ProjectReference"))
            {
                if (reference.PrimarySourceItem != null)
                {
                    referenceItem.SetMetadata(ItemMetadataNames.projectReferenceOriginalItemSpec, reference.PrimarySourceItem.GetMetadata("OriginalItemSpec"));
                }
            }

            return referenceItem;
        }
Exemplo n.º 4
0
        /// <summary>
        /// We have determined the given assembly reference is in the black list, we now need to find the primary references which caused it and make sure those are removed from the list of references.
        /// </summary>
        private void RemoveDependencyMarkedForExclusion(LogExclusionReason logExclusionReason, bool removeOnlyNoWarning, string subsetName, Dictionary<AssemblyNameExtension, Reference> goodReferences, List<Reference> removedReferences, AssemblyNameExtension assemblyName, Reference assemblyReference)
        {
            // For a dependency we would like to remove the primary references which caused this dependency to be found.
            // Source Items is the list of primary itemspecs which lead to the current reference being discovered. 
            ICollection dependees = assemblyReference.GetSourceItems();
            foreach (ITaskItem dependee in dependees)
            {
                string dependeeItemSpec = dependee.ItemSpec;

                if (assemblyReference.IsPrimary)
                {
                    // Dont process yourself
                    if (String.Compare(dependeeItemSpec, assemblyReference.PrimarySourceItem.ItemSpec, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        continue;
                    }
                }

                // Get the primary reference assemblyName
                AssemblyNameExtension primaryAssemblyName = GetReferenceFromItemSpec(dependeeItemSpec);

                if (primaryAssemblyName != null)
                {
                    // Get the specific primary reference which caused this dependency
                    Reference primaryAssemblyReference = _references[primaryAssemblyName];
                    bool hasSpecificVersionMetadata = primaryAssemblyReference.WantSpecificVersion;

                    if (!hasSpecificVersionMetadata)
                    {
                        // If the reference has not been removed we need to remove it and possibly remove it from the good reference list.
                        if (!removedReferences.Contains(primaryAssemblyReference))
                        {
                            removedReferences.Add(primaryAssemblyReference);
                            goodReferences.Remove(primaryAssemblyName);
                        }

                        if (!removeOnlyNoWarning && logExclusionReason != null)
                        {
                            logExclusionReason(false, assemblyName, assemblyReference, dependee, subsetName);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <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));
            }
        }
Exemplo n.º 6
0
 /// <summary>
 /// Show the files that made this dependency necessary.
 /// </summary>
 /// <param name="reference">The reference.</param>
 /// <param name="importance">The importance of the message.</param>
 private void LogDependees(Reference reference, MessageImportance importance)
 {
     if (!reference.IsPrimary)
     {
         ICollection dependees = reference.GetSourceItems();
         foreach (ITaskItem dependee in dependees)
         {
             Log.LogMessageFromResources(importance, "ResolveAssemblyReference.FourSpaceIndent", Log.FormatResourceString("ResolveAssemblyReference.RequiredBy", dependee.ItemSpec));
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Log the dependee and the item specs which caused the dependee reference to be resolved.
        /// </summary>
        /// <param name="dependeeReference"></param>
        private void LogDependeeReference(Reference dependeeReference)
        {
            Log.LogMessageFromResources(MessageImportance.Low, "ResolveAssemblyReference.EightSpaceIndent", dependeeReference.FullPath);

            Log.LogMessageFromResources(MessageImportance.Low, "ResolveAssemblyReference.TenSpaceIndent", ResourceUtilities.FormatResourceString("ResolveAssemblyReference.PrimarySourceItemsForReference", dependeeReference.FullPath));
            foreach (ITaskItem sourceItem in dependeeReference.GetSourceItems())
            {
                Log.LogMessageFromResources(MessageImportance.Low, "ResolveAssemblyReference.TwelveSpaceIndent", sourceItem.ItemSpec);
            }
        }
 private void LogDependees(Reference reference, MessageImportance importance)
 {
     if (!reference.IsPrimary)
     {
         foreach (ITaskItem item in reference.GetSourceItems())
         {
             base.Log.LogMessageFromResources(importance, "ResolveAssemblyReference.FourSpaceIndent", new object[] { base.Log.FormatResourceString("ResolveAssemblyReference.RequiredBy", new object[] { item.ItemSpec }) });
         }
     }
 }
 private void LogDependeeReference(Reference dependeeReference)
 {
     base.Log.LogMessageFromResources(MessageImportance.Low, "ResolveAssemblyReference.EightSpaceIndent", new object[] { dependeeReference.FullPath });
     base.Log.LogMessageFromResources(MessageImportance.Low, "ResolveAssemblyReference.TenSpaceIndent", new object[] { Microsoft.Build.Shared.ResourceUtilities.FormatResourceString("ResolveAssemblyReference.PrimarySourceItemsForReference", new object[] { dependeeReference.FullPath }) });
     foreach (ITaskItem item in dependeeReference.GetSourceItems())
     {
         base.Log.LogMessageFromResources(MessageImportance.Low, "ResolveAssemblyReference.TwelveSpaceIndent", new object[] { item.ItemSpec });
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Make this reference an assembly that is a dependency of 'sourceReference'
        ///
        /// For example, if 'sourceReference' is MyAssembly.dll then a dependent assembly file
        /// might be en\MyAssembly.resources.dll
        /// 
        /// Assembly references do not have their own dependencies, therefore they are
        /// </summary>
        /// <param name="sourceReference">The source reference that this reference will be dependent on</param>
        internal void MakeDependentAssemblyReference(Reference sourceReference)
        {
            _copyLocalState = CopyLocalState.Undecided;

            // This is a true dependency, so its not primary.
            _isPrimary = false;

            // This is an assembly file, so we'll need to find dependencies later.
            DependenciesFound = false;

            // Dependencies must always be specific version.
            _wantSpecificVersion = true;

            // Add source items from the original item.
            AddSourceItems(sourceReference.GetSourceItems());

            // Add dependees
            AddDependee(sourceReference);
        }
 private void RemoveDependencyMarkedForExclusion(LogExclusionReason logExclusionReason, bool removeOnlyNoWarning, string subsetName, Dictionary<AssemblyNameExtension, Reference> goodReferences, List<Reference> removedReferences, AssemblyNameExtension assemblyName, Reference assemblyReference)
 {
     foreach (ITaskItem item in assemblyReference.GetSourceItems())
     {
         string itemSpec = item.ItemSpec;
         if (!assemblyReference.IsPrimary || (string.Compare(itemSpec, assemblyReference.PrimarySourceItem.ItemSpec, StringComparison.OrdinalIgnoreCase) != 0))
         {
             AssemblyNameExtension referenceFromItemSpec = this.GetReferenceFromItemSpec(itemSpec);
             if (referenceFromItemSpec != null)
             {
                 Reference reference = this.references[referenceFromItemSpec];
                 if (!reference.WantSpecificVersion)
                 {
                     if (!removedReferences.Contains(reference))
                     {
                         removedReferences.Add(reference);
                         goodReferences.Remove(referenceFromItemSpec);
                     }
                     if (!removeOnlyNoWarning && (logExclusionReason != null))
                     {
                         logExclusionReason(false, assemblyName, assemblyReference, item, subsetName);
                     }
                 }
             }
         }
     }
 }
 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));
     }
 }
 private static ITaskItem SetItemMetadata(ArrayList relatedItems, ArrayList satelliteItems, ArrayList serializationAssemblyItems, ArrayList scatterItems, string fusionName, Reference reference)
 {
     ITaskItem destinationItem = new TaskItem {
         ItemSpec = reference.FullPath
     };
     destinationItem.SetMetadata("ResolvedFrom", reference.ResolvedSearchPath);
     if (reference.IsCopyLocal)
     {
         destinationItem.SetMetadata("CopyLocal", "true");
     }
     else
     {
         destinationItem.SetMetadata("CopyLocal", "false");
     }
     destinationItem.SetMetadata("FusionName", fusionName);
     if (!string.IsNullOrEmpty(reference.RedistName))
     {
         destinationItem.SetMetadata("Redist", reference.RedistName);
     }
     if (reference.IsRedistRoot == true)
     {
         destinationItem.SetMetadata("IsRedistRoot", "true");
     }
     else if (reference.IsRedistRoot == false)
     {
         destinationItem.SetMetadata("IsRedistRoot", "false");
     }
     if (reference.PrimarySourceItem != null)
     {
         reference.PrimarySourceItem.CopyMetadataTo(destinationItem);
     }
     else
     {
         foreach (ITaskItem item2 in reference.GetSourceItems())
         {
             item2.CopyMetadataTo(destinationItem);
         }
     }
     if (reference.ReferenceVersion != null)
     {
         destinationItem.SetMetadata("Version", reference.ReferenceVersion.ToString());
     }
     else
     {
         destinationItem.SetMetadata("Version", string.Empty);
     }
     foreach (string str in reference.GetRelatedFileExtensions())
     {
         ITaskItem item3 = new TaskItem(reference.FullPathWithoutExtension + str);
         destinationItem.CopyMetadataTo(item3);
         item3.SetMetadata("FusionName", "");
         relatedItems.Add(item3);
     }
     foreach (string str2 in reference.GetSatelliteFiles())
     {
         ITaskItem item4 = new TaskItem(Path.Combine(reference.DirectoryName, str2));
         destinationItem.CopyMetadataTo(item4);
         item4.SetMetadata("DestinationSubDirectory", Microsoft.Build.Shared.FileUtilities.EnsureTrailingSlash(Path.GetDirectoryName(str2)));
         item4.SetMetadata("FusionName", "");
         satelliteItems.Add(item4);
     }
     foreach (string str3 in reference.GetSerializationAssemblyFiles())
     {
         ITaskItem item5 = new TaskItem(Path.Combine(reference.DirectoryName, str3));
         destinationItem.CopyMetadataTo(item5);
         item5.SetMetadata("FusionName", "");
         serializationAssemblyItems.Add(item5);
     }
     foreach (string str4 in reference.GetScatterFiles())
     {
         ITaskItem item6 = new TaskItem(Path.Combine(reference.DirectoryName, str4));
         destinationItem.CopyMetadataTo(item6);
         item6.SetMetadata("FusionName", "");
         scatterItems.Add(item6);
     }
     return destinationItem;
 }
Exemplo n.º 14
0
        public void ReferenceTablePrimaryToPrimaryToDependencyWithOneInBlackList()
        {
            ReferenceTable referenceTable;
            MockEngine mockEngine;
            ResolveAssemblyReference rar;
            Hashtable blackList;
            AssemblyNameExtension engineAssemblyName = new AssemblyNameExtension("Microsoft.Build.Engine, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            AssemblyNameExtension xmlAssemblyName = new AssemblyNameExtension("System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            AssemblyNameExtension dataAssemblyName = new AssemblyNameExtension("System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a");
            Reference enginePrimaryReference = new Reference(isWinMDFile, fileExists, getRuntimeVersion);
            Reference xmlPrimaryReference = new Reference(isWinMDFile, fileExists, getRuntimeVersion);
            Reference dataDependencyReference = new Reference(isWinMDFile, fileExists, getRuntimeVersion);

            TaskItem taskItem = new TaskItem("Microsoft.Build.Engine");
            enginePrimaryReference.MakePrimaryAssemblyReference(taskItem, false, ".dll");
            enginePrimaryReference.FullPath = "FullPath";

            ITaskItem taskItem2 = new TaskItem("System.Xml");
            xmlPrimaryReference.FullPath = "FullPath";
            xmlPrimaryReference.MakePrimaryAssemblyReference(taskItem2, false, ".dll");
            // Make engine depend on xml primary when xml primary is a primary reference as well
            xmlPrimaryReference.AddSourceItems(enginePrimaryReference.GetSourceItems());
            xmlPrimaryReference.AddDependee(enginePrimaryReference);


            dataDependencyReference.FullPath = "FullPath";
            dataDependencyReference.MakeDependentAssemblyReference(xmlPrimaryReference);

            InitializeMockEngine(out referenceTable, out mockEngine, out rar);
            AddReferencesToReferenceTable(referenceTable, engineAssemblyName, dataAssemblyName, null, xmlAssemblyName, enginePrimaryReference, dataDependencyReference, null, xmlPrimaryReference);

            InitializeExclusionList(referenceTable, new AssemblyNameExtension[] { dataAssemblyName }, out blackList);


            string subsetName = ResolveAssemblyReference.GenerateSubSetName(new string[] { "Client" }, null);
            string warningMessage = rar.Log.FormatResourceString("ResolveAssemblyReference.FailBecauseDependentAssemblyInExclusionList", taskItem.ItemSpec, dataAssemblyName.FullName, subsetName);
            string warningMessage2 = rar.Log.FormatResourceString("ResolveAssemblyReference.FailBecauseDependentAssemblyInExclusionList", taskItem2.ItemSpec, dataAssemblyName.FullName, subsetName);
            mockEngine.AssertLogContains(warningMessage);
            mockEngine.AssertLogContains(warningMessage2);

            Dictionary<AssemblyNameExtension, Reference> table = referenceTable.References;
            Assert.False(table.ContainsKey(xmlAssemblyName)); // "Expected to not find the xmlAssemblyName in the referenceList"
            Assert.False(table.ContainsKey(engineAssemblyName)); // "Expected to not find the engineAssemblyName in the referenceList"
            Assert.False(table.ContainsKey(dataAssemblyName)); // "Expected to not find the dataAssemblyName in the referenceList"
        }
 internal void MakeDependentAssemblyReference(Reference sourceReference)
 {
     this.copyLocalState = CopyLocalState.Undecided;
     this.isPrimary = false;
     this.DependenciesFound = false;
     this.wantSpecificVersion = true;
     this.AddSourceItems(sourceReference.GetSourceItems());
     this.AddDependee(sourceReference);
 }