Skip to content

Commit

Permalink
Merge branch 'mholo65-feature/GH-2161' into develop
Browse files Browse the repository at this point in the history
* mholo65-feature/GH-2161:
  (GH-2161) Make NuGet.Config path absolute.
  • Loading branch information
devlead committed Jun 14, 2019
2 parents e3550d2 + 630eb9a commit 8847c24
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/Cake.NuGet/Install/NuGetPackageInstaller.cs
Expand Up @@ -76,13 +76,13 @@ static NuGetPackageInstaller()
_currentFramework = NuGetFramework.Parse(_environment.Runtime.BuiltFramework.FullName, DefaultFrameworkNameProvider.Instance);
_nugetLogger = new NuGetLogger(_log);

var nugetConfig = GetNuGetConfigPath(_environment, _config);
var nugetConfig = GetNuGetConfigPath(_environment, _config, _fileSystem);
var nugetConfigDirectoryPath = nugetConfig.Item1;
var nugetConfigFilePath = nugetConfig.Item2;

_log.Debug(nugetConfigFilePath != null
? $"Found NuGet.config at: {nugetConfigFilePath}"
: "NuGet.config not found.");
? $"Found NuGet Config at: {nugetConfigDirectoryPath}/{nugetConfigFilePath}"
: "NuGet Config not specified. Will use NuGet default mechanism for resolving it.");

_nugetSettings = Settings.LoadDefaultSettings(
nugetConfigDirectoryPath.FullPath,
Expand Down Expand Up @@ -323,15 +323,20 @@ private static NuGetVersion GetNuGetVersion(PackageReference package, IEnumerabl
}
}

private static Tuple<DirectoryPath, FilePath> GetNuGetConfigPath(ICakeEnvironment environment, ICakeConfiguration config)
private static Tuple<DirectoryPath, FilePath> GetNuGetConfigPath(ICakeEnvironment environment, ICakeConfiguration config, IFileSystem fileSystem)
{
DirectoryPath rootPath;
FilePath filePath;

var nugetConfigFile = config.GetValue(Constants.NuGet.ConfigFile);
if (!string.IsNullOrEmpty(nugetConfigFile))
{
var configFilePath = new FilePath(nugetConfigFile);
var configFilePath = new FilePath(nugetConfigFile).MakeAbsolute(environment);

if (!fileSystem.Exist(configFilePath))
{
throw new System.IO.FileNotFoundException("NuGet Config file not found.", configFilePath.FullPath);
}

rootPath = configFilePath.GetDirectory();
filePath = configFilePath.GetFilename();
Expand Down

0 comments on commit 8847c24

Please sign in to comment.