/// <summary> /// Gets the package sources of the specified project. /// </summary> /// <param name="project">An <see cref="IMSBuildItem" /> representing the project..</param> /// <param name="innerNodes">An <see cref="IReadOnlyCollection{IMSBuildItem}" /> containing the inner nodes of the project if its targets multiple frameworks.</param> /// <param name="settings">The <see cref="ISettings" /> of the specified project.</param> /// <returns>A <see cref="List{PackageSource}" /> object containing the packages sources for the specified project.</returns> internal static List <PackageSource> GetSources(IMSBuildProject project, IReadOnlyCollection <IMSBuildProject> innerNodes, ISettings settings) { return(BuildTasksUtility.GetSources( project.Directory, project.SplitPropertyValueOrNull("RestoreSources"), project.SplitPropertyValueOrNull("RestoreSourcesOverride"), innerNodes.SelectMany(i => MSBuildStringUtility.Split(i.GetProperty("RestoreAdditionalProjectSources"))), settings) .Select(i => new PackageSource(i)) .ToList()); }
public void GetSources_WithRestoreSourcesGlobal_Property_ResolvesAgainstWorkingDirectory() { using (var testDir = TestDirectory.CreateInTemp()) { // Arrange var startupDirectory = Path.Combine(testDir, "startup"); var projectDirectory = Path.Combine(testDir, "project"); var relativePath = "relativeSource"; // Act var effectiveSources = BuildTasksUtility.GetSources( startupDirectory: startupDirectory, projectDirectory: projectDirectory, sources: new string[] { relativePath }, sourcesOverride: new string[] { relativePath }, additionalProjectSources: Array.Empty <string>(), settings: NullSettings.Instance ); // Assert effectiveSources.ShouldBeEquivalentTo(new[] { Path.Combine(startupDirectory, relativePath) }); } }