Exemplo n.º 1
0
        /// <summary>
        /// Helper to get a ProjectMetadataElement for a simple metadatum
        /// </summary>
        private static ProjectMetadataElement GetMetadataXml()
        {
            string content = @"
                    <Project xmlns='http://schemas.microsoft.com/developer/msbuild/2003' >
                        <ItemGroup>
                            <i Include='i1'>
                                <m Condition='c'>m1</m>
                            </i>
                        </ItemGroup>
                    </Project>
                ";

            ProjectRootElement      project   = ProjectRootElement.Create(XmlReader.Create(new StringReader(content)));
            ProjectItemGroupElement itemGroup = (ProjectItemGroupElement)Helpers.GetFirst(project.Children);
            ProjectItemElement      item      = Helpers.GetFirst(itemGroup.Items);
            ProjectMetadataElement  metadata  = Helpers.GetFirst(item.Metadata);

            return(metadata);
        }
Exemplo n.º 2
0
        public static void AddMetadata(this ProjectItemElement item, ProjectMetadataElement metadata)
        {
            var existingMetadata = item.GetMetadataWithName(metadata.Name);

            if (existingMetadata != default(ProjectMetadataElement) && !existingMetadata.ValueEquals(metadata))
            {
                throw new Exception(LocalizableStrings.CannotMergeMetadataError);
            }

            if (existingMetadata == default(ProjectMetadataElement))
            {
#if !DISABLE_TRACE
                MigrationTrace.Instance.WriteLine(String.Format(LocalizableStrings.AddingMetadataToItem, nameof(AddMetadata), item.ItemType, metadata.Name, metadata.Value, metadata.Condition));
#endif
                var metametadata = item.AddMetadata(metadata.Name, metadata.Value);
                metametadata.Condition            = metadata.Condition;
                metametadata.ExpressedAsAttribute = metadata.ExpressedAsAttribute;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Sets a new metadata value on the ItemDefinition.
        /// </summary>
        /// <remarks>Unevaluated value is assumed to be escaped as necessary</remarks>
        public ProjectMetadata SetMetadataValue(string name, string unevaluatedValue)
        {
            if (Link != null)
            {
                return(Link.SetMetadataValue(name, unevaluatedValue));
            }

            XmlUtilities.VerifyThrowArgumentValidElementName(name);
            ErrorUtilities.VerifyThrowArgument(!FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name), "ItemSpecModifierCannotBeCustomMetadata", name);
            ErrorUtilities.VerifyThrowInvalidOperation(!XMakeElements.ReservedItemNames.Contains(name), "CannotModifyReservedItemMetadata", name);

            ProjectMetadata metadatum;

            if (_metadata != null)
            {
                metadatum = _metadata[name];

                if (metadatum != null)
                {
                    Project.VerifyThrowInvalidOperationNotImported(metadatum.Xml.ContainingProject);
                    metadatum.UnevaluatedValue = unevaluatedValue;
                    return(metadatum);
                }
            }

            // We can't use the item definition that this object came from as a root, as it doesn't map directly
            // to a single XML element. Instead, add a new one to the project. Best we can do.
            ProjectItemDefinitionElement itemDefinition = _project.Xml.AddItemDefinition(_itemType);

            ProjectMetadataElement metadatumXml = itemDefinition.AddMetadata(name, unevaluatedValue);

            _metadata = _metadata ?? new PropertyDictionary <ProjectMetadata>();

            string evaluatedValueEscaped = _project.ExpandMetadataValueBestEffortLeaveEscaped(this, unevaluatedValue, metadatumXml.Location);

            metadatum = new ProjectMetadata(this, metadatumXml, evaluatedValueEscaped, null /* predecessor unknown */);

            _metadata.Set(metadatum);

            return(metadatum);
        }
        private void SetPackageVersion(ProjectItemElement packageRef, NuGetVersion version, ProjectRootElement packagesProps)
        {
            if (packagesProps == null)
            {
                packageRef.AddMetadata("Version", version.ToString(), expressAsAttribute: true);
                return;
            }

            ProjectItemElement commonPackageVersion = packagesProps.Items
                                                      .FirstOrDefault(i => i.ItemType.Equals("PackageVersion", StringComparison.OrdinalIgnoreCase) &&
                                                                      i.Include.Equals(packageRef.Include, StringComparison.OrdinalIgnoreCase));

            string versionStr = $"[{version.ToNormalizedString()}]";

            if (commonPackageVersion != null)
            {
                ProjectMetadataElement commonVersion = commonPackageVersion.Metadata.FirstOrDefault(i => i.Name.Equals("Version"));
                if (commonVersion != null)
                {
                    if (!versionStr.Equals(commonVersion.Value.ToString()))
                    {
                        throw new InvalidDataException($"For package {packageRef.Include} version {version} conflicts with {commonVersion.Value} [project {packageRef.ContainingProject.FullPath}]");
                    }
                    return;
                }
            }

            ProjectItemGroupElement commonPackagesGroup = packagesProps.ItemGroups.SingleOrDefault(g => g.Label.Equals(CommonPackagesGroupLabel, StringComparison.OrdinalIgnoreCase));

            if (commonPackagesGroup == null)
            {
                throw new InvalidOperationException($"{packagesProps.FullPath} is expected to contain ItemGroup with label '{CommonPackagesGroupLabel}'");
            }

            ProjectItemElement commonVersionItem = commonPackagesGroup.AddItem("PackageVersion", packageRef.Include.ToString());

            commonVersionItem.AddMetadata("Version", versionStr.ToString(), expressAsAttribute: true);
        }
Exemplo n.º 5
0
        public void SingleTargetFramework()
        {
            LockFile lockFile = GetLockFileWithSingleTargetFramework();

            ProjectRootElement project = ValidateProject(lockFile);

            ProjectItemGroupElement itemGroupElement = project.ItemGroups.ShouldHaveSingleItem();

            foreach (LockFileTargetLibrary targetLibrary in lockFile.Targets[0].Libraries)
            {
                ProjectItemElement itemElement = itemGroupElement.Items.FirstOrDefault(x => x.Include.Equals(targetLibrary.Name));

                itemElement.ShouldNotBeNull();

                ProjectMetadataElement versionMetadataElement = itemElement.Metadata.FirstOrDefault(x => x.Name.Equals("Version"));

                versionMetadataElement.ShouldNotBeNull();

                versionMetadataElement.Value.ShouldBe($"[{targetLibrary.Version.ToString()}]");
            }

            itemGroupElement.Items.Count.ShouldBe(lockFile.Targets.Aggregate(0, (count, target) => target.Libraries.Count));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Adds metadata with the specified name and value to the item.
        /// Updates an existing metadata if one already exists with the same name on the item directly, as opposed to inherited from an item definition.
        /// Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example,
        /// if a piece of metadata named "m" is added on item of type "i", it does not affect "j" which is evaluated from "@(j->'%(m)')" until reevaluation.
        /// Also if the unevaluated value of "m" is set to something that is modified by evaluation, such as "$(p)", the evaluated value will be set to literally "$(p)" until reevaluation.
        /// This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state.
        /// Returns the new or existing metadatum.
        /// </summary>
        /// <remarks>Unevaluated value is assumed to be escaped as necessary</remarks>
        public ProjectMetadata SetMetadataValue(string name, string unevaluatedValue)
        {
            Project.VerifyThrowInvalidOperationNotImported(_xml.ContainingProject);

            XmlUtilities.VerifyThrowArgumentValidElementName(name);
            ErrorUtilities.VerifyThrowArgument(!FileUtilities.ItemSpecModifiers.IsItemSpecModifier(name), "ItemSpecModifierCannotBeCustomMetadata", name);
            ErrorUtilities.VerifyThrowInvalidOperation(XMakeElements.IllegalItemPropertyNames[name] == null, "CannotModifyReservedItemMetadata", name);
            ErrorUtilities.VerifyThrowInvalidOperation(_xml.Parent != null && _xml.Parent.Parent != null, "OM_ObjectIsNoLongerActive");

            _project.SplitItemElementIfNecessary(_xml);

            ProjectMetadata metadatum;

            if (_directMetadata != null)
            {
                metadatum = _directMetadata[name];

                if (metadatum != null)
                {
                    metadatum.UnevaluatedValue = unevaluatedValue;
                    return(metadatum);
                }
            }

            ProjectMetadataElement metadatumXml = _xml.AddMetadata(name, unevaluatedValue);

            _directMetadata = _directMetadata ?? new PropertyDictionary <ProjectMetadata>();

            string evaluatedValueEscaped = _project.ExpandMetadataValueBestEffortLeaveEscaped(this, unevaluatedValue, metadatumXml.Location);

            metadatum = new ProjectMetadata(this, metadatumXml, evaluatedValueEscaped, null /* predecessor unknown */);

            _directMetadata.Set(metadatum);

            return(metadatum);
        }
Exemplo n.º 7
0
        public void SingleTargetFrameworkWithIncludeAssetsAndPrivateAssets()
        {
            LockFile lockFile = GetLockFileWithSingleTargetFramework();

            ProjectRootElement project = ValidateProject(lockFile);

            ProjectItemGroupElement itemGroupElement = project.ItemGroups.ShouldHaveSingleItem();

            itemGroupElement.Items.ShouldContain(i => i.Include.Equals("Package3"), 1);

            var itemElement = itemGroupElement.Items.Single(i => i.Include.Equals("Package3"));

            ProjectMetadataElement includeAssetsMetadataElement = itemElement.Metadata.FirstOrDefault(i => i.Name.Equals("IncludeAssets"));

            includeAssetsMetadataElement.ShouldNotBeNull();

            includeAssetsMetadataElement.Value.ShouldBe("Runtime;ContentFiles");

            ProjectMetadataElement privateAssetsMetadataElement = itemElement.Metadata.FirstOrDefault(i => i.Name.Equals("PrivateAssets"));

            privateAssetsMetadataElement.ShouldNotBeNull();

            privateAssetsMetadataElement.Value.ShouldBe("Native");
        }
Exemplo n.º 8
0
        public void SetNameIllegal()
        {
            ProjectMetadataElement metadatum = GetMetadataXml();

            metadatum.Name = "ImportGroup";
        }
 public static bool ValueEquals(this ProjectMetadataElement metadata, ProjectMetadataElement otherMetadata)
 {
     return(metadata.Value.Equals(otherMetadata.Value, StringComparison.Ordinal));
 }
        /// <summary>
        /// Sets a new metadata value.  Called by the evaluator only.
        /// Discards predecessor as this information is only useful at design time.
        /// </summary>
        ProjectMetadataInstance IItemDefinition <ProjectMetadataInstance> .SetMetadata(ProjectMetadataElement xml, string evaluatedValue, ProjectMetadataInstance predecessor)
        {
            // No mutability check as this is used during creation (evaluation)
            _metadata = _metadata ?? new CopyOnWritePropertyDictionary <ProjectMetadataInstance>();

            ProjectMetadataInstance metadatum = new ProjectMetadataInstance(xml.Name, evaluatedValue);

            _metadata[xml.Name] = metadatum;

            return(metadatum);
        }
Exemplo n.º 11
0
 public void AddProjectReference(string projectName, string projectFilePath)
 {
     Microsoft.Build.Evaluation.ProjectItem reference = _project.AddItem("ProjectReference", PathUtilities.MakeRelative(FilePath, projectFilePath)).First();
     ProjectMetadataElement projectElement            = reference.Xml.AddMetadata("Name", projectName);
 }
Exemplo n.º 12
0
        private static bool IsGuidValue(ProjectMetadataElement e)
        {
            Guid g;

            return(Guid.TryParse(e.Value, out g));
        }
Exemplo n.º 13
0
        public void HashFileIsLowerCased()
        {
            const string sha512FileName = "pAcKaGe1.1.0.0.nUpKg.sHA512";

            LockFile lockFile = new LockFile
            {
                Libraries = new List <LockFileLibrary>
                {
                    new LockFileLibrary
                    {
                        Path    = "package1/1.0.0",
                        Name    = "Package1",
                        Version = new NuGetVersion(1, 0, 0),
                        Sha512  = "3473C4E0C7F5404F8F46311CA3631331",
                        Type    = "package",
                        Files   = new List <string>
                        {
                            sha512FileName
                        }
                    }
                },
                Targets = new List <LockFileTarget>
                {
                    new LockFileTarget
                    {
                        TargetFramework = NuGetFramework.ParseFolder("net46"),
                        Libraries       = new List <LockFileTargetLibrary>
                        {
                            new LockFileTargetLibrary
                            {
                                Name    = "Package1",
                                Type    = "package",
                                Version = new NuGetVersion(1, 0, 0)
                            }
                        }
                    }
                },
                PackageSpec = new PackageSpec
                {
                    Name             = "foo",
                    TargetFrameworks =
                    {
                        new TargetFrameworkInformation
                        {
                            FrameworkName = NuGetFramework.ParseFolder("net46"),
                            Dependencies  = new List <LibraryDependency>
                            {
                                new LibraryDependency
                                {
                                    LibraryRange = new LibraryRange("Package1", VersionRange.Parse("1.0.0"), LibraryDependencyTarget.Package)
                                }
                            }
                        }
                    }
                }
            };

            ProjectRootElement project = ValidateProject(lockFile);

            ProjectItemElement packageReference = project.Items.Where(i => i.ItemType.Equals("PackageReference")).ShouldHaveSingleItem();

            ProjectMetadataElement hashFileMetadata = packageReference.Metadata.Where(i => i.Name.Equals(GenerateLockedPackageReferencesFile.HashfileMetadataName)).ShouldHaveSingleItem();

            hashFileMetadata.Value.ShouldBe(sha512FileName.ToLowerInvariant());
        }
Exemplo n.º 14
0
 internal ProjectMetadata(Project project, string itemType, IEnumerable <ProjectMetadata> existingMetadata, Action <ProjectMetadata> remover, ProjectMetadataElement xml)
 {
     this.xml     = xml;
     this.project = project;
     item_type    = itemType;
     predecessor  = existingMetadata.FirstOrDefault(m => m.Name == xml.Name);
     if (predecessor != null)
     {
         remover(predecessor);
     }
     is_imported = Project.ProjectCollection.OngoingImports.Any();
 }
Exemplo n.º 15
0
        public void SetInvalidNullValue()
        {
            ProjectMetadataElement metadatum = GetMetadataXml();

            metadatum.Value = null;
        }
        private static bool UpgadeCppConfiguration(Microsoft.Build.Evaluation.Project project, OldConfiguration cfg)
        {
            ProjectPropertyGroupElement propertyGroup = project.Xml.PropertyGroups.FirstOrDefault(g => g.Label.Equals("IceBuilder"));

            if (propertyGroup == null)
            {
                propertyGroup       = project.Xml.AddPropertyGroup();
                propertyGroup.Label = "IceBuilder";
            }

            if (!string.IsNullOrEmpty(cfg.OutputDir))
            {
                propertyGroup.AddProperty(PropertyNames.OutputDir, cfg.OutputDir);
            }

            if (!string.IsNullOrEmpty(cfg.HeaderExt))
            {
                propertyGroup.AddProperty(PropertyNames.HeaderExt, cfg.HeaderExt);
            }

            if (!string.IsNullOrEmpty(cfg.SourceExt))
            {
                propertyGroup.AddProperty(PropertyNames.SourceExt, cfg.SourceExt);
            }

            if (!string.IsNullOrEmpty(cfg.AdditionalOptions))
            {
                propertyGroup.AddProperty(PropertyNames.AdditionalOptions, cfg.AdditionalOptions);
            }

            if (!string.IsNullOrEmpty(cfg.IncludeDirectories))
            {
                propertyGroup.AddProperty(PropertyNames.IncludeDirectories,
                                          string.Format("{0};$({1})", cfg.IncludeDirectories, PropertyNames.IncludeDirectories));
            }

            if (cfg.Stream)
            {
                propertyGroup.AddProperty(PropertyNames.Stream, "True");
            }

            if (cfg.Checksum)
            {
                propertyGroup.AddProperty(PropertyNames.Checksum, "True");
            }

            if (cfg.Ice)
            {
                propertyGroup.AddProperty(PropertyNames.AllowIcePrefix, "True");
            }

            if (!string.IsNullOrEmpty(cfg.DLLExport))
            {
                propertyGroup.AddProperty(PropertyNames.DLLExport, cfg.DLLExport);
            }

            foreach (ProjectItemDefinitionGroupElement group in project.Xml.ItemDefinitionGroups)
            {
                //
                // Remove old property sheet from all configurations
                //
                IEnumerable <ProjectImportElement> imports = project.Xml.Imports.Where(
                    p => p.Project.Equals("$(ALLUSERSPROFILE)\\ZeroC\\Ice.props"));
                if (imports != null)
                {
                    foreach (ProjectImportElement import in imports)
                    {
                        import.Parent.RemoveChild(import);
                    }
                }
                //
                // WinRT SDK old property sheet
                //
                imports = project.Xml.Imports.Where(
                    p => p.Project.IndexOf("CommonConfiguration\\Neutral\\Ice.props") != -1);
                if (imports != null)
                {
                    foreach (ProjectImportElement import in imports)
                    {
                        import.Parent.RemoveChild(import);
                    }
                }

                foreach (ProjectItemDefinitionElement i in group.ItemDefinitions)
                {
                    if (i.ItemType.Equals("ClCompile"))
                    {
                        if (!string.IsNullOrEmpty(cfg.OutputDir))
                        {
                            ProjectMetadataElement metaData = i.Metadata.FirstOrDefault(
                                e => e.Name.Equals("AdditionalIncludeDirectories"));

                            if (metaData != null)
                            {
                                List <string> values = new List <string>(metaData.Value.Split(new char[] { ';' }));
                                values.Remove(cfg.OutputDir);
                                metaData.Value = string.Join(";", values);

                                if (values.Count == 0 ||
                                    (values.Count == 1 && values[0].Equals("%(AdditionalIncludeDirectories)")))
                                {
                                    i.RemoveChild(metaData);
                                }
                                else
                                {
                                    if (!values.Contains("%(AdditionalIncludeDirectories)"))
                                    {
                                        values.Add("%(AdditionalIncludeDirectories)");
                                    }
                                    metaData.Value = string.Join(";", values);
                                }
                            }
                        }
                    }
                    else if (i.ItemType.Equals("Link"))
                    {
                        ProjectMetadataElement metaData = i.Metadata.FirstOrDefault(
                            e => e.Name.Equals("AdditionalDependencies"));

                        if (metaData != null)
                        {
                            List <string> values = new List <string>(metaData.Value.Split(new char[] { ';' }));
                            foreach (string name in Package.CppLibNames)
                            {
                                values.Remove(string.Format("{0}.lib", name));
                                values.Remove(string.Format("{0}d.lib", name));
                            }

                            if (values.Count == 0 || (values.Count == 1 && values[0].Equals("%(AdditionalDependencies)")))
                            {
                                i.RemoveChild(metaData);
                            }
                            else
                            {
                                metaData.Value = string.Join(";", values);
                            }
                        }

                        metaData = i.Metadata.FirstOrDefault(e => e.Name.Equals("AdditionalLibraryDirectories"));
                        if (metaData != null)
                        {
                            if (metaData.Value.Equals("%(AdditionalLibraryDirectories)"))
                            {
                                i.RemoveChild(metaData);
                            }
                        }
                    }
                }
            }

            List <ProjectItem> sliceItems =
                project.GetItems("None").Where(item => Path.GetExtension(item.UnevaluatedInclude).Equals(".ice")).ToList();

            //
            // Default output directory has changed
            //
            if (string.IsNullOrEmpty(cfg.OutputDir))
            {
                foreach (string itemType in new string[] { "ClInclude", "ClCompile" })
                {
                    project.GetItems(itemType).Where(
                        item =>
                    {
                        return(sliceItems.FirstOrDefault(
                                   slice =>
                        {
                            return slice.UnevaluatedInclude.Equals(Path.ChangeExtension(item.UnevaluatedInclude, ".ice"));
                        }) != null);
                    })
                    .ToList()
                    .ForEach(item => project.RemoveItem(item));
                }
            }

            sliceItems.ForEach(item =>
            {
                project.RemoveItem(item);
                project.AddItem("IceBuilder", item.UnevaluatedInclude);
            });
            return(true);
        }
Exemplo n.º 17
0
        protected virtual bool ParseReferenceItems(IList <ProjectInfo> referencedProjects)
        {
            ICollection <ProjectItemElement> allItems          = _project.Items;
            List <ProjectItemElement>        references        = new List <ProjectItemElement>();
            List <ProjectItemElement>        comReferences     = new List <ProjectItemElement>();
            List <ProjectItemElement>        projectReferences = new List <ProjectItemElement>();

            foreach (ProjectItemElement item in allItems)
            {
                switch (item.ItemType)
                {
                case "Reference":
                    references.Add(item);
                    break;

                case "COMReference":
                    comReferences.Add(item);
                    break;

                case "ProjectReference":
                    projectReferences.Add(item);
                    break;
                }
            }

            IList <string> referencedAssemblies      = this.ReferencedAssemblies;
            IList <string> referencedKnownAssemblies = this.ReferencedKnownAssemblies;

            foreach (ProjectItemElement item in references)
            {
                string referenceInclude = item.Include;
                if (referenceInclude.IndexOf(',') > 0)
                {
                    AssemblyName asmName = new AssemblyName(referenceInclude);

                    referenceInclude = asmName.Name;
                }

                string referencedAssembly = referenceInclude + ".dll";
                if (ProjectSectionFactory.IsKnownAssemblyName(referencedAssembly))
                {
                    referencedKnownAssemblies.Add(referencedAssembly);
                    continue;
                }

                if (item.HasMetadata)
                {
                    ProjectMetadataElement hintMetadata = null;

                    foreach (ProjectMetadataElement metadata in item.Metadata)
                    {
                        if (String.Equals(metadata.Name, "HintPath",
                                          StringComparison.OrdinalIgnoreCase))
                        {
                            hintMetadata = metadata;
                            break;
                        }
                    }

                    if (hintMetadata != null)
                    {
                        string fullPath = Path.GetFullPath(
                            Path.Combine(this.ProjectDir, hintMetadata.Value));
                        if (File.Exists(fullPath))
                        {
                            referencedAssemblies.Add(fullPath);
                        }
                    }
                }
                else if (!String.IsNullOrEmpty(this.OutputType))
                {
                    // Trying some possibilities...
                    string extension = null;
                    switch (this.OutputType.ToLower())
                    {
                    case "dll":
                    case "library":
                    case "dynamiclibrary":
                        extension = ".dll";
                        break;

                    case "exe":
                    case "application":
                        extension = ".exe";
                        break;
                    }
                    if (!String.IsNullOrEmpty(extension))
                    {
                        // A referenced file in the project directory...
                        string fullPath = Path.GetFullPath(Path.Combine(this.ProjectDir,
                                                                        referenceInclude + extension));
                        if (!File.Exists(fullPath) && (!String.IsNullOrEmpty(this.OutputPath) &&
                                                       Directory.Exists(this.OutputPath)))
                        {
                            // A referenced file in the output directory...
                            fullPath = Path.GetFullPath(Path.Combine(
                                                            this.OutputPath, referenceInclude + extension));
                        }
                        if (!String.IsNullOrEmpty(fullPath) && File.Exists(fullPath))
                        {
                            referencedAssemblies.Add(fullPath);
                        }
                    }
                }
            }

            foreach (ProjectItemElement item in comReferences)
            {
                //string referenceInclude = item.Include;
                //if (referenceInclude.IndexOf(',') > 0)
                //{
                //    AssemblyName asmName = new AssemblyName(referenceInclude);

                //    referenceInclude = asmName.Name;
                //}

                //if (item.HasMetadata)
                //{
                //    foreach (ProjectMetadataElement metadata in item.Metadata)
                //    {
                //    }
                //}
            }

            foreach (ProjectItemElement item in projectReferences)
            {
                string referenceInclude = item.Include;

                if (String.IsNullOrEmpty(referenceInclude) || !item.HasMetadata)
                {
                    continue;
                }

                string projectName = String.Empty;
                string projectGuid = String.Empty;
                foreach (ProjectMetadataElement metadata in item.Metadata)
                {
                    if (String.Equals(metadata.Name, "Project",
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        projectGuid = metadata.Value;
                    }
                    else if (String.Equals(metadata.Name, "Name",
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        projectName = metadata.Value;
                    }
                }

                string projectPath = String.Empty;
                if (Path.IsPathRooted(referenceInclude))
                {
                    projectPath = Path.GetFullPath(referenceInclude);
                }
                else
                {
                    projectPath = Path.GetFullPath(
                        Path.Combine(this.ProjectDir, referenceInclude));
                }

                if (File.Exists(projectPath))
                {
                    if (String.IsNullOrEmpty(projectName))
                    {
                        projectName = Path.GetFileNameWithoutExtension(projectPath);
                    }

                    ProjectInfo projectInfo = new ProjectInfo(projectPath,
                                                              projectGuid, projectName);
                    if (projectInfo.IsValid)
                    {
                        referencedProjects.Add(projectInfo);
                    }
                }
                else
                {
                    if (!String.IsNullOrEmpty(projectGuid))
                    {
                        // If the path does not exist, we try looking through
                        // any available list of references...
                        ProjectInfo projectInfo = this.Context.GetProjectInfo(
                            projectGuid);
                        if (projectInfo != null && projectInfo.IsValid)
                        {
                            referencedProjects.Add(projectInfo);
                        }
                    }
                }
            }

            return(true);
        }
Exemplo n.º 18
0
 /// <summary>
 /// Construct a new EvaluatorMetadata
 /// </summary>
 public EvaluatorMetadata(ProjectMetadataElement xml, string evaluatedValueEscaped)
 {
     this.Xml = xml;
     this.EvaluatedValueEscaped = evaluatedValueEscaped;
 }
Exemplo n.º 19
0
 public VSProjectMetadataElement(ProjectMetadataElement element) : base(element)
 {
     this.Name  = element.Name;
     this.Value = element.Value;
 }