public IList<ResourceDescriptor> GetResources(Project project) { string root = PathUtility.EnsureTrailingSlash(project.ProjectDirectory); return project .Files.ResourceFiles .Where(res => !ResxResourceProvider.IsResxResourceFile(res.Key)) .Select(resourceFile => { string resourceName; string rootNamespace; if (string.IsNullOrEmpty(resourceFile.Value)) { // No logical name, so use the file name resourceName = ResourcePathUtility.GetResourceName(root, resourceFile.Key); rootNamespace = project.Name; } else { resourceName = CreateCSharpManifestResourceName.EnsureResourceExtension(resourceFile.Value, resourceFile.Key); rootNamespace = null; } return new ResourceDescriptor() { FileName = Path.GetFileName(resourceName), Name = CreateCSharpManifestResourceName.CreateManifestName(resourceName, rootNamespace), StreamFactory = () => new FileStream(resourceFile.Key, FileMode.Open, FileAccess.Read, FileShare.Read) }; }) .ToList(); }
public ExecResult Restore( Project project, string packagesDir = null, IEnumerable<string> feeds = null, string additionalArguments = null) { return Restore(project.ProjectDirectory, packagesDir, feeds, additionalArguments); }
public ApplicationEnvironment(Project project, FrameworkName targetFramework, string configuration, IApplicationEnvironment hostEnvironment) { _project = project; _targetFramework = targetFramework; Configuration = configuration; _globalData = new ApplicationGlobalData(hostEnvironment); }
public BuildLoadContext(Project project, CompilationEngine compilationEngine, CompilationEngineContext compilationEngineContext) { _project = project; _compilationEngine = compilationEngine; _compilationEngineContext = compilationEngineContext; }
public DesignTimeAssemblyLoadContextFactory(Project project, IApplicationEnvironment appEnv, CompilationEngineFactory compilationFactory) { _project = project; _appEnv = appEnv; _compilationFactory = compilationFactory; }
public ProjectDescription GetDescription(FrameworkName targetFramework, Project project) { // This never returns null var targetFrameworkInfo = project.GetTargetFramework(targetFramework); var targetFrameworkDependencies = new List<LibraryDependency>(targetFrameworkInfo.Dependencies); if (targetFramework != null && VersionUtility.IsDesktop(targetFramework)) { targetFrameworkDependencies.Add(new LibraryDependency { LibraryRange = new LibraryRange("mscorlib", frameworkReference: true) }); targetFrameworkDependencies.Add(new LibraryDependency { LibraryRange = new LibraryRange("System", frameworkReference: true) }); if (targetFramework.Version >= Constants.Version35) { targetFrameworkDependencies.Add(new LibraryDependency { LibraryRange = new LibraryRange("System.Core", frameworkReference: true) }); if (targetFramework.Version >= Constants.Version40) { targetFrameworkDependencies.Add(new LibraryDependency { LibraryRange = new LibraryRange("Microsoft.CSharp", frameworkReference: true) }); } } } var dependencies = project.Dependencies.Concat(targetFrameworkDependencies).ToList(); var loadableAssemblies = new List<string>(); if (project.IsLoadable) { loadableAssemblies.Add(project.Name); } // Mark the library as unresolved if there were specified frameworks // and none of them resolved bool unresolved = targetFrameworkInfo.FrameworkName == null; return new ProjectDescription( new LibraryRange(project.Name, frameworkReference: false), project, dependencies, loadableAssemblies, targetFrameworkInfo, !unresolved); }
public BuildLoadContext(Project project, CompilationEngine compilationEngine, CompilationEngineContext compilationEngineContext, string configuration) { _project = project; _compilationEngine = compilationEngine; _compilationEngineContext = compilationEngineContext; _configuration = configuration; }
private static DnxProject GetProject(string path) { var cacheKey = Tuple.Create("Project", path); return(cache.Get <DnxProject>(cacheKey, ctx => { DnxProject project; DnxProject.TryGetProject(path, out project); return project; })); }
internal static SourceUnit FromProject(Project project, string root) { var su = new SourceUnit { Name = project.Name, Dir = Utils.GetRelativePath(project.ProjectDirectory, root), Files = project.Files.SourceFiles.Select(p => Utils.GetRelativePath(p, root)).OrderByDescending(p => p).ToArray(), Dependencies = project.Dependencies.Select(DependencyInfo.FromLibraryDependency).ToArray(), Ops = new Dictionary<string, string> { { "depresolve", null } } }; return su; }
public bool IsValidForProject(Project project, out string message) { if (Version != Constants.LockFileVersion) { message = $"The expected lock file version does not match the actual version"; return false; } message = $"Dependencies in {Project.ProjectFileName} were modified"; var actualTargetFrameworks = project.GetTargetFrameworks(); // The lock file should contain dependencies for each framework plus dependencies shared by all frameworks if (ProjectFileDependencyGroups.Count != actualTargetFrameworks.Count() + 1) { return false; } foreach (var group in ProjectFileDependencyGroups) { IOrderedEnumerable<string> actualDependencies; var expectedDependencies = group.Dependencies.OrderBy(x => x); // If the framework name is empty, the associated dependencies are shared by all frameworks if (string.IsNullOrEmpty(group.FrameworkName)) { actualDependencies = project.Dependencies.Select(x => x.LibraryRange.ToString()).OrderBy(x => x); } else { var framework = actualTargetFrameworks .FirstOrDefault(f => string.Equals(f.FrameworkName.ToString(), group.FrameworkName, StringComparison.Ordinal)); if (framework == null) { return false; } actualDependencies = framework.Dependencies.Select(d => d.LibraryRange.ToString()).OrderBy(x => x); } if (!actualDependencies.SequenceEqual(expectedDependencies)) { return false; } } message = null; return true; }
public LibraryExporter CreateProjectExporter(Project project, FrameworkName targetFramework, string configuration) { // This library manager represents the graph that will be used to resolve // references (compiler /r in csc terms) var libraryManager = _context.ProjectGraphProvider.GetProjectGraph(project, targetFramework); // This library manager represents the graph that will be used to *load* the compiler and other // build time related dependencies var runtimeLibraryManager = _context.ProjectGraphProvider.GetProjectGraph(project, _context.ApplicationEnvironment.RuntimeFramework); var loadContext = new RuntimeLoadContext(runtimeLibraryManager, this, _context.DefaultLoadContext); return new LibraryExporter(libraryManager, loadContext, this, configuration); }
static IEnumerable<LibraryDescription> GetAllDeps(Project proj) => proj.GetTargetFrameworks().Select(f => f.FrameworkName) .SelectMany(f => { var context = new ApplicationHostContext { Project = proj, TargetFramework = f }; return ApplicationHostContext.GetRuntimeLibraries(context).Skip(1); // the first one is the self-reference }) .Distinct(LibraryUtils.Comparer) .OrderBy(l => l.Identity?.Name);
public LibraryExporter CreateProjectExporter(Project project, FrameworkName targetFramework, string configuration) { // This library manager represents the graph that will be used to resolve // references (compiler /r in csc terms) var context = new ApplicationHostContext { Project = project, TargetFramework = targetFramework }; ApplicationHostContext.Initialize(context); return new LibraryExporter(context.LibraryManager, this, configuration); }
public Assembly LoadProject(Project project, string aspect, IAssemblyLoadContext loadContext) { // Export the project var export = ProjectExporter.ExportProject(project, this, aspect, _context.TargetFramework, _context.Configuration); // Load the metadata reference foreach (var projectReference in export.MetadataReferences.OfType<IMetadataProjectReference>()) { if (string.Equals(projectReference.Name, project.Name, StringComparison.OrdinalIgnoreCase)) { return projectReference.Load(loadContext); } } return null; }
public LibraryManager GetProjectGraph(Project project, FrameworkName targetFramework) { // TODO: Cache sub-graph walk? // Create a child app context for this graph walk var context = new ApplicationHostContext { Project = project, TargetFramework = targetFramework }; ApplicationHostContext.Initialize(context); // Return the results return context.LibraryManager; }
private static ApplicationHostContext GetApplicationHostContext(DnxProject project, string configuration, FrameworkName frameworkName) { var cacheKey = Tuple.Create("ApplicationContext", project.Name, configuration, frameworkName); return(cache.Get <ApplicationHostContext>(cacheKey, ctx => { var applicationHostContext = new ApplicationHostContext { ProjectDirectory = project.ProjectDirectory, TargetFramework = frameworkName }; ApplicationHostContext.Initialize(applicationHostContext); return applicationHostContext; })); }
private static string ResolvePath(Project project, string configuration, string path) { if (string.IsNullOrEmpty(path)) { return null; } if (Path.DirectorySeparatorChar == '/') { path = path.Replace('\\', Path.DirectorySeparatorChar); } else { path = path.Replace('/', Path.DirectorySeparatorChar); } path = path.Replace("{configuration}", configuration); return Path.Combine(project.ProjectDirectory, path); }
private static ApplicationHostContext GetApplicationHostContext(DnxProject project, string configuration, FrameworkName frameworkName) { var cacheKey = Tuple.Create("ApplicationContext", project.Name, configuration, frameworkName); return cache.Get<ApplicationHostContext>(cacheKey, ctx => { var applicationHostContext = new ApplicationHostContext { ProjectDirectory = project.ProjectDirectory, TargetFramework = frameworkName }; ApplicationHostContext.Initialize(applicationHostContext); return applicationHostContext; }); }
public Assembly LoadProject(Project project, string aspect, IAssemblyLoadContext loadContext) { var exporter = CreateProjectExporter(project, _context.ApplicationEnvironment.RuntimeFramework, _context.ApplicationEnvironment.Configuration); // Export the project var export = exporter.GetExport(project.Name, aspect); // Load the metadata reference foreach (var projectReference in export.MetadataReferences.OfType<IMetadataProjectReference>()) { if (string.Equals(projectReference.Name, project.Name, StringComparison.OrdinalIgnoreCase)) { return projectReference.Load(loadContext); } } return null; }
public IEnumerable<LibraryDescription> GetProjectGraph(Project project, FrameworkName targetFramework, string configuration) { // TODO: Cache sub-graph walk? // Create a child app context for this graph walk var context = new ApplicationHostContext( _hostServices, project.ProjectDirectory, packagesDirectory: null, configuration: configuration, targetFramework: targetFramework); // Walk the graph context.DependencyWalker.Walk(project.Name, project.Version, targetFramework); // Return the results return context.DependencyWalker.Libraries; }
public ProjectDescription( LibraryRange libraryRange, Project project, IEnumerable<LibraryDependency> dependencies, IEnumerable<string> assemblies, FrameworkName framework, bool resolved) : base(libraryRange, new LibraryIdentity(project.Name, project.Version, isGacOrFrameworkReference: false), project.ProjectFilePath, LibraryTypes.Project, dependencies, assemblies, framework) { Project = project; Resolved = resolved; Compatible = resolved; }
public Assembly LoadProject(Project project, FrameworkName targetFramework, string aspect, IAssemblyLoadContext loadContext, AssemblyName assemblyName, string configuration) { var exporter = CreateProjectExporter(project, targetFramework, configuration); // Export the project var export = exporter.GetExport(project.Name, aspect); if (export == null) { return null; } // Load the metadata reference foreach (var projectReference in export.MetadataReferences.OfType<IMetadataProjectReference>()) { if (string.Equals(projectReference.Name, project.Name, StringComparison.OrdinalIgnoreCase)) { return projectReference.Load(assemblyName, loadContext); } } return null; }
private static Graph ForTarget(Project project, LockFileTarget target) { var name = VersionUtility.GetShortFrameworkName(target.TargetFramework); if (!string.IsNullOrEmpty(target.RuntimeIdentifier)) { name += "-" + target.RuntimeIdentifier; } var graph = new Graph(name); foreach (var lib in target.Libraries) { foreach (var dep in lib.Dependencies) { graph.AddLink(lib.Name, dep.Id); } } foreach (var dep in project.Dependencies) { graph.AddLink(project.Name, dep.Name); } return graph; }
static IEnumerable<LibraryDescription> GetAllDeps(Project proj) => proj.GetTargetFrameworks().Select(f => f.FrameworkName) .SelectMany(f => { var context = new ApplicationHostContext { Project = proj, TargetFramework = f }; IList<LibraryDescription> libs = null; while (libs == null) { try { libs = ApplicationHostContext.GetRuntimeLibraries(context); } catch (Exception e) { } } // the first library description is always self-reference, so skip it return libs.Skip(1); }) .Distinct(LibraryUtils.Comparer) .OrderBy(l => l.Identity?.Name);
public IAssemblyLoadContext CreateBuildLoadContext(Project project) { // This load context represents the graph that will be used to *load* the compiler and other // build time related dependencies return new BuildLoadContext(project, this, _context); }
public IList<ResourceDescriptor> GetResources(Project project) { return _providers .SelectMany(provider => provider.GetResources(project)) .ToList(); }
/// <summary> /// Parse a Json object which represents project configuration for a specified framework /// </summary> /// <param name="frameworkKey">The name of the framework</param> /// <param name="frameworkValue">The Json object represent the settings</param> /// <returns>Returns true if it successes.</returns> private bool BuildTargetFrameworkNode(Project project, string frameworkKey, JsonObject frameworkValue) { // If no compilation options are provided then figure them out from the node var compilerOptions = GetCompilationOptions(frameworkValue) ?? new CompilerOptions(); var frameworkName = FrameworkNameHelper.ParseFrameworkName(frameworkKey); // If it's not unsupported then keep it if (frameworkName == VersionUtility.UnsupportedFrameworkName) { // REVIEW: Should we skip unsupported target frameworks return false; } // Add the target framework specific define var defines = new HashSet<string>(compilerOptions.Defines ?? Enumerable.Empty<string>()); var frameworkDefinition = Tuple.Create(frameworkKey, frameworkName); var frameworkDefine = FrameworkNameHelper.MakeDefaultTargetFrameworkDefine(frameworkDefinition); if (!string.IsNullOrEmpty(frameworkDefine)) { defines.Add(frameworkDefine); } compilerOptions.Defines = defines; var targetFrameworkInformation = new TargetFrameworkInformation { FrameworkName = frameworkName, Dependencies = new List<LibraryDependency>() }; var frameworkDependencies = new List<LibraryDependency>(); PopulateDependencies( project.ProjectFilePath, frameworkDependencies, frameworkValue, "dependencies", isGacOrFrameworkReference: false); var frameworkAssemblies = new List<LibraryDependency>(); PopulateDependencies( project.ProjectFilePath, frameworkAssemblies, frameworkValue, "frameworkAssemblies", isGacOrFrameworkReference: true); frameworkDependencies.AddRange(frameworkAssemblies); targetFrameworkInformation.Dependencies = frameworkDependencies; targetFrameworkInformation.WrappedProject = frameworkValue.ValueAsString("wrappedProject"); var binNode = frameworkValue.ValueAsJsonObject("bin"); if (binNode != null) { targetFrameworkInformation.AssemblyPath = binNode.ValueAsString("assembly"); targetFrameworkInformation.PdbPath = binNode.ValueAsString("pdb"); } project._compilerOptionsByFramework[frameworkName] = compilerOptions; project._targetFrameworks[frameworkName] = targetFrameworkInformation; return true; }
private void BuildTargetFrameworksAndConfigurations(Project project, JsonObject projectJsonObject, ICollection<DiagnosticMessage> diagnostics) { // Get the shared compilationOptions project._defaultCompilerOptions = GetCompilationOptions(projectJsonObject) ?? new CompilerOptions(); project._defaultTargetFrameworkConfiguration = new TargetFrameworkInformation { Dependencies = new List<LibraryDependency>() }; // Add default configurations project._compilerOptionsByConfiguration["Debug"] = new CompilerOptions { Defines = new[] { "DEBUG", "TRACE" }, Optimize = false }; project._compilerOptionsByConfiguration["Release"] = new CompilerOptions { Defines = new[] { "RELEASE", "TRACE" }, Optimize = true }; // The configuration node has things like debug/release compiler settings /* { "configurations": { "Debug": { }, "Release": { } } } */ var configurationsSection = projectJsonObject.ValueAsJsonObject("configurations"); if (configurationsSection != null) { foreach (var configKey in configurationsSection.Keys) { var compilerOptions = GetCompilationOptions(configurationsSection.ValueAsJsonObject(configKey)); // Only use this as a configuration if it's not a target framework project._compilerOptionsByConfiguration[configKey] = compilerOptions; } } // The frameworks node is where target frameworks go /* { "frameworks": { "net45": { }, "dnxcore50": { } } } */ var frameworks = projectJsonObject.ValueAsJsonObject("frameworks"); if (frameworks != null) { foreach (var frameworkKey in frameworks.Keys) { try { var frameworkToken = frameworks.ValueAsJsonObject(frameworkKey); var success = BuildTargetFrameworkNode(project, frameworkKey, frameworkToken); if (!success) { diagnostics?.Add( new DiagnosticMessage( DiagnosticMonikers.NU1008, $"\"{frameworkKey}\" is an unsupported framework.", project.ProjectFilePath, DiagnosticMessageSeverity.Error, frameworkToken.Line, frameworkToken.Column)); } } catch (Exception ex) { throw FileFormatException.Create(ex, frameworks.Value(frameworkKey), project.ProjectFilePath); } } } }
public Project ReadProject(Stream stream, string projectName, string projectPath, ICollection<DiagnosticMessage> diagnostics) { var project = new Project(); var reader = new StreamReader(stream); var rawProject = JsonDeserializer.Deserialize(reader) as JsonObject; if (rawProject == null) { throw FileFormatException.Create( "The JSON file can't be deserialized to a JSON object.", projectPath); } // Meta-data properties project.Name = projectName; project.ProjectFilePath = Path.GetFullPath(projectPath); var version = rawProject.Value("version") as JsonString; if (version == null) { project.Version = new SemanticVersion("1.0.0"); } else { try { var buildVersion = Environment.GetEnvironmentVariable("DNX_BUILD_VERSION"); project.Version = SpecifySnapshot(version, buildVersion); } catch (Exception ex) { throw FileFormatException.Create(ex, version, project.ProjectFilePath); } } var fileVersion = Environment.GetEnvironmentVariable("DNX_ASSEMBLY_FILE_VERSION"); if (string.IsNullOrWhiteSpace(fileVersion)) { project.AssemblyFileVersion = project.Version.Version; } else { try { var simpleVersion = project.Version.Version; project.AssemblyFileVersion = new Version(simpleVersion.Major, simpleVersion.Minor, simpleVersion.Build, int.Parse(fileVersion)); } catch (FormatException ex) { throw new FormatException("The assembly file version is invalid: " + fileVersion, ex); } } project.Description = rawProject.ValueAsString("description"); project.Summary = rawProject.ValueAsString("summary"); project.Copyright = rawProject.ValueAsString("copyright"); project.Title = rawProject.ValueAsString("title"); project.EntryPoint = rawProject.ValueAsString("entryPoint"); project.ProjectUrl = rawProject.ValueAsString("projectUrl"); project.LicenseUrl = rawProject.ValueAsString("licenseUrl"); project.IconUrl = rawProject.ValueAsString("iconUrl"); project.Authors = rawProject.ValueAsStringArray("authors") ?? new string[] { }; project.Owners = rawProject.ValueAsStringArray("owners") ?? new string[] { }; project.Tags = rawProject.ValueAsStringArray("tags") ?? new string[] { }; project.Language = rawProject.ValueAsString("language"); project.ReleaseNotes = rawProject.ValueAsString("releaseNotes"); project.RequireLicenseAcceptance = rawProject.ValueAsBoolean("requireLicenseAcceptance", defaultValue: false); project.IsLoadable = rawProject.ValueAsBoolean("loadable", defaultValue: true); // TODO: Move this to the dependencies node project.EmbedInteropTypes = rawProject.ValueAsBoolean("embedInteropTypes", defaultValue: false); project.Dependencies = new List<LibraryDependency>(); // Project files project.Files = new ProjectFilesCollection(rawProject, project.ProjectDirectory, project.ProjectFilePath); var compilerInfo = rawProject.ValueAsJsonObject("compiler"); if (compilerInfo != null) { var languageName = compilerInfo.ValueAsString("name") ?? "C#"; var compilerAssembly = compilerInfo.ValueAsString("compilerAssembly"); var compilerType = compilerInfo.ValueAsString("compilerType"); var compiler = new TypeInformation(compilerAssembly, compilerType); project.CompilerServices = new CompilerServices(languageName, compiler); } var commands = rawProject.Value("commands") as JsonObject; if (commands != null) { foreach (var key in commands.Keys) { var value = commands.ValueAsString(key); if (value != null) { project.Commands[key] = value; } } } var scripts = rawProject.Value("scripts") as JsonObject; if (scripts != null) { foreach (var key in scripts.Keys) { var stringValue = scripts.ValueAsString(key); if (stringValue != null) { project.Scripts[key] = new string[] { stringValue }; continue; } var arrayValue = scripts.ValueAsStringArray(key); if (arrayValue != null) { project.Scripts[key] = arrayValue; continue; } throw FileFormatException.Create( string.Format("The value of a script in {0} can only be a string or an array of strings", Project.ProjectFileName), scripts.Value(key), project.ProjectFilePath); } } BuildTargetFrameworksAndConfigurations(project, rawProject, diagnostics); PopulateDependencies( project.ProjectFilePath, project.Dependencies, rawProject, "dependencies", isGacOrFrameworkReference: false); return project; }
private static string GetProjectRelativeFullPath(DnxProject project, string path) { return(Path.GetFullPath(Path.Combine(project.ProjectDirectory, path))); }
private static DependencyInformation ResolveDependencyInfo(DnxProject project, FrameworkName frameworkName) { var cacheKey = Tuple.Create("DependencyInformation", project.Name, "Debug", frameworkName); return(cache.Get <DependencyInformation>(cacheKey, ctx => { var applicationHostContext = GetApplicationHostContext(project, "Debug", frameworkName); var info = new DependencyInformation { HostContext = applicationHostContext, ProjectReferences = new List <ProjectReference>(), References = new List <string>(), ExportedSourcesFiles = new List <string>() }; foreach (var library in applicationHostContext.LibraryManager.GetLibraryDescriptions()) { // Skip unresolved libraries if (!library.Resolved) { continue; } if (string.Equals(library.Type, "Project") && !string.Equals(library.Identity.Name, project.Name)) { DnxProject referencedProject = GetProject(library.Path); if (referencedProject == null) { // Should never happen continue; } var targetFrameworkInformation = referencedProject.GetTargetFramework(library.Framework); // If this is an assembly reference then treat it like a file reference if (!string.IsNullOrEmpty(targetFrameworkInformation.AssemblyPath) && string.IsNullOrEmpty(targetFrameworkInformation.WrappedProject)) { string assemblyPath = GetProjectRelativeFullPath(referencedProject, targetFrameworkInformation.AssemblyPath); info.References.Add(assemblyPath); } else { string wrappedProjectPath = null; if (!string.IsNullOrEmpty(targetFrameworkInformation.WrappedProject)) { wrappedProjectPath = GetProjectRelativeFullPath(referencedProject, targetFrameworkInformation.WrappedProject); } info.ProjectReferences.Add(new ProjectReference { Name = referencedProject.Name, Framework = library.Framework, Path = library.Path, WrappedProjectPath = wrappedProjectPath, Project = referencedProject }); } } } var libraryExporter = new LibraryExporter( applicationHostContext.LibraryManager, null, "Debug"); var exportWithoutProjects = libraryExporter.GetNonProjectExports(project.Name); foreach (var reference in exportWithoutProjects.MetadataReferences) { var fileReference = reference as IMetadataFileReference; if (fileReference != null) { info.References.Add(fileReference.Path); } } foreach (var sourceFileReference in exportWithoutProjects.SourceReferences.OfType <ISourceFileReference>()) { info.ExportedSourcesFiles.Add(sourceFileReference.Path); } return info; })); }
public ApplicationEnvironment(Project project, FrameworkName targetFramework, IApplicationEnvironment hostEnvironment) { _project = project; _targetFramework = targetFramework; }
private static string GetProjectRelativeFullPath(DnxProject project, string path) { return Path.GetFullPath(Path.Combine(project.ProjectDirectory, path)); }
private static DependencyInformation ResolveDependencyInfo(DnxProject project, FrameworkName frameworkName) { var cacheKey = Tuple.Create("DependencyInformation", project.Name, "Debug", frameworkName); return cache.Get<DependencyInformation>(cacheKey, ctx => { var applicationHostContext = GetApplicationHostContext(project, "Debug", frameworkName); var info = new DependencyInformation { HostContext = applicationHostContext, ProjectReferences = new List<ProjectReference>(), References = new List<string>(), ExportedSourcesFiles = new List<string>() }; foreach (var library in applicationHostContext.LibraryManager.GetLibraryDescriptions()) { // Skip unresolved libraries if (!library.Resolved) { continue; } if (string.Equals(library.Type, "Project") && !string.Equals(library.Identity.Name, project.Name)) { DnxProject referencedProject = GetProject(library.Path); if (referencedProject == null) { // Should never happen continue; } var targetFrameworkInformation = referencedProject.GetTargetFramework(library.Framework); // If this is an assembly reference then treat it like a file reference if (!string.IsNullOrEmpty(targetFrameworkInformation.AssemblyPath) && string.IsNullOrEmpty(targetFrameworkInformation.WrappedProject)) { string assemblyPath = GetProjectRelativeFullPath(referencedProject, targetFrameworkInformation.AssemblyPath); info.References.Add(assemblyPath); } else { string wrappedProjectPath = null; if (!string.IsNullOrEmpty(targetFrameworkInformation.WrappedProject)) { wrappedProjectPath = GetProjectRelativeFullPath(referencedProject, targetFrameworkInformation.WrappedProject); } info.ProjectReferences.Add(new ProjectReference { Name = referencedProject.Name, Framework = library.Framework, Path = library.Path, WrappedProjectPath = wrappedProjectPath, Project = referencedProject }); } } } var libraryExporter = new LibraryExporter( applicationHostContext.LibraryManager, null, "Debug"); var exportWithoutProjects = libraryExporter.GetNonProjectExports(project.Name); foreach (var reference in exportWithoutProjects.MetadataReferences) { var fileReference = reference as IMetadataFileReference; if (fileReference != null) { info.References.Add(fileReference.Path); } } foreach (var sourceFileReference in exportWithoutProjects.SourceReferences.OfType<ISourceFileReference>()) { info.ExportedSourcesFiles.Add(sourceFileReference.Path); } return info; }); }