Beispiel #1
0
        private void AddProjectDependencies(IList <EmbeddedItemInfo> itemsToEmbed, bool compress, string projectPath)
        {
            if (!String.IsNullOrEmpty(projectPath))
            {
                var projectDir    = System.IO.Path.GetDirectoryName(projectPath);
                var loadedProject = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.GetLoadedProjects(projectPath).FirstOrDefault();
                if (loadedProject == null)
                {
                    return;
                }

                var dependencyProjects = from x in loadedProject.AllEvaluatedItems
                                         where x.ItemType == "ProjectReference"
                                         select x;
                foreach (var project in dependencyProjects)
                {
                    var depPath = Path.Combine(projectDir, project.EvaluatedInclude);
                    depPath = Path.GetFullPath(depPath); // to remove "/../../" in depPath
                    var depLoadedProject = Microsoft.Build.Evaluation.ProjectCollection.GlobalProjectCollection.GetLoadedProjects(depPath).FirstOrDefault();
                    if (depLoadedProject == null)
                    {
                        continue;
                    }

                    var dependencyDllPath = depLoadedProject.GetPropertyValue("TargetPath");
                    var depEmbedInfo      = new EmbeddedItemInfo(dependencyDllPath, compress);
                    itemsToEmbed.Add(depEmbedInfo);
                    RemoveFromLocals(dependencyDllPath, true);
                    AddProjectDependencies(itemsToEmbed, compress, depPath);
                }
            }
        }
Beispiel #2
0
        private ICollection <EmbeddedItemInfo> PrepareItemsToEmbed()
        {
            List <EmbeddedItemInfo> itemsToEmbed = new List <EmbeddedItemInfo>();

            foreach (var reference in _referenses)
            {
                var embedAssembly = Attributes.IsTrue(reference.GetMetadata(Attributes.EmbedAssemblyName));
                if (embedAssembly)
                {
                    var compress  = Attributes.IsTrue(reference.GetMetadata(Attributes.CompressEmbededDataName));
                    var embedInfo = new EmbeddedItemInfo(reference, compress);
                    itemsToEmbed.Add(embedInfo);
                    _removedLocals.Add(reference);
                    var possibleDocPath = Path.ChangeExtension(embedInfo.Path, "xml");
                    RemoveFromLocals(possibleDocPath);

                    //PreparePdb(itemsToEmbed, reference, compress, embedInfo.Path);
                    var embedAssemblyDependensies = Attributes.IsTrue(reference.GetMetadata(Attributes.EmbedAssemblyDependenciesName));
                    if (embedAssemblyDependensies)
                    {
                        var projectPath = reference.GetMSBuildSourceProjectFile();
                        AddProjectDependencies(itemsToEmbed, compress, projectPath);
                    }
                }
            }

            return(itemsToEmbed);
        }
Beispiel #3
0
        private void PreparePdb(List <EmbeddedItemInfo> itemsToEmbed, ITaskItem reference, bool compress, string assemblyPath)
        {
            var embedAssemblyPdb = Attributes.IsTrue(reference.GetMetadata(Attributes.EmbedAssemblyPdbName));

            if (embedAssemblyPdb)
            {
                var possiblePdbPath = Path.ChangeExtension(assemblyPath, "pdb");
                if (!String.IsNullOrEmpty(possiblePdbPath) && File.Exists(possiblePdbPath))
                {
                    var pdbItemInfo = new EmbeddedItemInfo(possiblePdbPath, compress);
                    itemsToEmbed.Add(pdbItemInfo);
                    RemoveFromLocals(pdbItemInfo.Path);
                }
            }
        }