Skip to content

Commit

Permalink
Added a ThrowIfNotAvailable to ISolutionManager.
Browse files Browse the repository at this point in the history
Updated BuildIntegratedProjectUtility to handle cases where
solutionDirectory is null or is a relative path

Fixes NuGet/Home#1081
  • Loading branch information
unknown committed Aug 11, 2015
1 parent 81cd9f8 commit 3b9b8ff
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/PackageManagement/IDE/ISolutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public interface ISolutionManager
/// passed in.
/// </returns>
NuGetProject GetNuGetProject(string nuGetProjectSafeName);

void ThrowIfNotAvailable();
}

public class NuGetProjectEventArgs : EventArgs
Expand Down
11 changes: 10 additions & 1 deletion src/ProjectManagement/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/ProjectManagement/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@
<data name="RemovingPackageFromMSBuildProject" xml:space="preserve">
<value>Removing package '{0}' from project '{1}'</value>
</data>
<data name="SolutionDirectoryShouldBeANonNullFullPath" xml:space="preserve">
<value>Solution directory must be a non-null full path</value>
</data>
<data name="TokenHasNoValue" xml:space="preserve">
<value>The replacement token '{0}' has no value</value>
</data>
Expand Down
13 changes: 10 additions & 3 deletions src/ProjectManagement/Utility/BuildIntegratedProjectUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ public static class BuildIntegratedProjectUtility

public static string GetEffectiveGlobalPackagesFolder(string solutionDirectory, ISettings settings)
{
// solutionDirectory could be null or empty. If not, it should be a full path, not a relative path
Debug.Assert(string.IsNullOrEmpty(solutionDirectory) || Path.IsPathRooted(solutionDirectory));
if (settings == null)
{
throw new ArgumentNullException(nameof(settings));
}

var globalPackagesFolder = SettingsUtility.GetGlobalPackagesFolder(settings);
if (string.IsNullOrEmpty(solutionDirectory))
if (Path.IsPathRooted(globalPackagesFolder))
{
return globalPackagesFolder;
}

if (string.IsNullOrEmpty(solutionDirectory) || !Path.IsPathRooted(solutionDirectory))
{
throw new ArgumentException(Strings.SolutionDirectoryShouldBeANonNullFullPath);
}

return Path.GetFullPath(Path.Combine(solutionDirectory, globalPackagesFolder));
}

Expand Down
5 changes: 5 additions & 0 deletions test/Test.Utility/TestSolutionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@ public bool IsSolutionOpen
get { return NuGetProjects.Count > 0; }
}

public void ThrowIfNotAvailable()
{

}

public INuGetProjectContext NuGetProjectContext { get; set; }

#pragma warning disable 0067
Expand Down

0 comments on commit 3b9b8ff

Please sign in to comment.