/// <summary>
 /// Gets the packages path for the specified project.
 /// </summary>
 /// <param name="project">The <see cref="IMSBuildItem" /> representing the project.</param>
 /// <param name="settings">The <see cref="ISettings" /> of the project.</param>
 /// <returns>The full path to the packages directory for the specified project.</returns>
 internal static string GetPackagesPath(IMSBuildProject project, ISettings settings)
 {
     return(RestoreSettingsUtils.GetValue(
                () => UriUtility.GetAbsolutePath(project.Directory, project.GetProperty("RestorePackagesPathOverride")),
                () => UriUtility.GetAbsolutePath(project.Directory, project.GetProperty("RestorePackagesPath")),
                () => SettingsUtility.GetGlobalPackagesFolder(settings)));
 }
Exemple #2
0
 public void GetRestoreSettingsTask_GetValueGetLastValue()
 {
     RestoreSettingsUtils.GetValue(
         () => null,
         () => null,
         () => Array.Empty <string>()).Should().BeEquivalentTo(Array.Empty <string>());
 }
Exemple #3
0
 public void GetRestoreSettingsTask_GetValueGetFirstValue()
 {
     RestoreSettingsUtils.GetValue(
         () => "a",
         () => "b",
         () => null).Should().Be("a");
 }
Exemple #4
0
 public void GetRestoreSettingsTask_GetValueGetLastValue()
 {
     RestoreSettingsUtils.GetValue(
         () => null,
         () => null,
         () => new string[0]).ShouldBeEquivalentTo(new string[0]);
 }
        /// <summary>
        /// Gets the repository path for the specified project.
        /// </summary>
        /// <param name="project">The <see cref="IMSBuildItem" /> representing the project.</param>
        /// <param name="settings">The <see cref="ISettings" /> of the specified project.</param>
        /// <returns>The repository path of the specified project.</returns>
        internal static string GetRepositoryPath(IMSBuildProject project, ISettings settings)
        {
            return(RestoreSettingsUtils.GetValue(
                       () => UriUtility.GetAbsolutePath(project.Directory, project.GetProperty("RestoreRepositoryPathOverride")),
                       () => UriUtility.GetAbsolutePath(project.Directory, project.GetProperty("RestoreRepositoryPath")),
                       () => SettingsUtility.GetRepositoryPath(settings),
                       () =>
            {
                string solutionDir = project.GetProperty("SolutionPath");

                solutionDir = string.Equals(solutionDir, "*Undefined*", StringComparison.OrdinalIgnoreCase)
                        ? project.Directory
                        : Path.GetDirectoryName(solutionDir);

                return UriUtility.GetAbsolutePath(solutionDir, PackagesConfig.PackagesNodeName);
            }));
        }
Exemple #6
0
 public void GetRestoreSettingsTask_GetValueAllNull()
 {
     RestoreSettingsUtils.GetValue <string[]>(
         () => null,
         () => null).Should().BeNull();
 }