public ProjectReference(ISolution solution, Microsoft.Build.Evaluation.ProjectItem projectItem)
        {
            OriginalProjectItem = projectItem;
            Include             = projectItem.EvaluatedInclude;

            var fullPath = Path.GetFullPath(Path.Combine(projectItem.Project.DirectoryPath, Include));

            File    = Wrapper.Wrap(new FileInfo(fullPath));
            Project = solution.GetProjectByAbsoluteProjectFilePath(fullPath);

            Guid referencedProjectGuid;

            if (Guid.TryParse(projectItem.GetMetadataValue("Project"), out referencedProjectGuid))
            {
                ReferencedProjectGuid = referencedProjectGuid;
            }

            ReferencedProjectName = projectItem.GetMetadataValue("Name");
        }
Beispiel #2
0
 public string GetName()
 {
     if (_projectItemInCaseOfProjectLoadedWithEnvDTE != null)
     {
         return(_projectItemInCaseOfProjectLoadedWithEnvDTE.Name);
     }
     else if (_projectItemInCaseOfProjectLoadedWithMsBuild != null)
     {
         string fullPath = _projectItemInCaseOfProjectLoadedWithMsBuild.GetMetadataValue("FullPath");
         return(System.IO.Path.GetFileName(fullPath));
     }
     else if (_folderWalkerInCaseOfProjectLoadedWithMsBuild != null)
     {
         return(_folderWalkerInCaseOfProjectLoadedWithMsBuild.Name);
     }
     else
     {
         throw new InvalidOperationException("Project item is null.");
     }
 }
Beispiel #3
0
        string GetAssemblyFileNameFromHintPath(Microsoft.Build.Evaluation.Project p, Microsoft.Build.Evaluation.ProjectItem item)
        {
            string assemblyFileName = null;

            if (item.HasMetadata("HintPath"))
            {
                assemblyFileName = _fileSystem.Path.Combine(p.DirectoryPath, item.GetMetadataValue("HintPath")).ForceNativePathSeparator();
                _logger.Info("Looking for assembly from HintPath at " + assemblyFileName);
                if (!_fileSystem.File.Exists(assemblyFileName))
                {
                    _logger.Info("Did not find assembly from HintPath");
                    assemblyFileName = null;
                }
            }
            return(assemblyFileName);
        }
Beispiel #4
0
 public static string GetMetadataValue(Microsoft.Build.Evaluation.ProjectItem item, string name)
 {
     return(item.GetMetadataValue(name));
 }