示例#1
0
        /// <summary>
        /// Loads the references.
        /// </summary>
        /// <returns></returns>
        private IEnumerable<AssemblyReference> LoadReferences()
        {
            if (Project == null)
                yield break;

            var references = Project.Items.Where(i => i.ItemType == "Reference").ToArray();
            foreach (var reference in references)
            {
                var hintPath = reference.Metadata.SingleOrDefault(m => m.Name == "HintPath");
                if (hintPath != null)
                {
                    var fullPath = Path.Combine(_projectDirectory, hintPath.EvaluatedValue);
                    // when <HintPath> is provided, the assembly is private by default
                    yield return new AssemblyReference(_assemblyResolver, fullPath, IsPrivate(reference) ?? true, reference);
                }
                else
                {
                    var assemblyName = new AssemblyName(reference.EvaluatedInclude);
                    yield return new AssemblyReference(_assemblyResolver, assemblyName, IsPrivate(reference) ?? false, reference);
                }
            }
            var projectReferences = Project.Items.Where(i => i.ItemType == "ProjectReference").ToArray();
            foreach (var projectReference in projectReferences)
            {
                var isPrivate = IsPrivate(projectReference) ?? true;
                var projectPath = Path.Combine(_projectDirectory, projectReference.EvaluatedInclude);
                var referencedProject = new ProjectDefinition(projectPath, _outputDirectory, _globalProperties, _assemblyResolver, _projectCollection);
                if (referencedProject.Project == null)
                    continue;
                var targetPath = GetTargetPath(referencedProject, isPrivate);
                yield return new AssemblyReference(_assemblyResolver, targetPath, isPrivate, referencedProject);
            }
        }
示例#2
0
        private string GetTargetPath(ProjectDefinition referencedProject, bool isPrivate)
        {
            if (!isPrivate)
                return referencedProject.TargetPath;

            var referenceFileName = Path.GetFileName(referencedProject.TargetPath);
            var targetPath = Path.Combine(_outputDirectory, referenceFileName);
            return targetPath;
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectDefinitionLoadErrorEventArgs"/> class.
 /// </summary>
 /// <param name="e">The e.</param>
 /// <param name="projectDefinition">The project definition.</param>
 public ProjectDefinitionLoadErrorEventArgs(Exception e, ProjectDefinition projectDefinition)
 {
     Exception         = e;
     ProjectDefinition = projectDefinition;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AssemblyReference" /> class.
 /// </summary>
 /// <param name="assemblyResolver">The assembly resolver.</param>
 /// <param name="path">The path.</param>
 /// <param name="isPrivate">if set to <c>true</c> [is private].</param>
 /// <param name="projectDefinition">The project definition.</param>
 public AssemblyReference(IAssemblyResolver assemblyResolver, string path, bool isPrivate, ProjectDefinition projectDefinition)
 {
     _assemblyResolver = assemblyResolver;
     Path              = System.IO.Path.GetFullPath(path);
     IsPrivate         = isPrivate;
     ProjectDefinition = projectDefinition;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProjectDefinitionLoadErrorEventArgs"/> class.
 /// </summary>
 /// <param name="e">The e.</param>
 /// <param name="projectDefinition">The project definition.</param>
 public ProjectDefinitionLoadErrorEventArgs(Exception e, ProjectDefinition projectDefinition)
 {
     Exception = e;
     ProjectDefinition = projectDefinition;
 }