Fixing failures in tests when the user has a fallbackfolder setup on this machine already. These failures are again due to the fact that --packages are not populated when the packages are found in the fallback folder.
This commit is contained in:
parent
dee8725fd2
commit
3d0089552c
13 changed files with 43 additions and 35 deletions
|
@ -13,7 +13,8 @@
|
|||
|
||||
<NuGetPackagesArchiveProject>$(IntermediateDirectory)/NuGetPackagesArchiveProject</NuGetPackagesArchiveProject>
|
||||
<NuGetPackagesArchiveFolder>$(IntermediateDirectory)/NuGetPackagesArchiveFolder</NuGetPackagesArchiveFolder>
|
||||
<LZMANuGetConfigFilePath>$(NuGetPackagesArchiveProject)/Nuget.config</LZMANuGetConfigFilePath>
|
||||
<LZMANuGetConfigFilePath Condition=" '$(CLI_LZMA_PACKAGE_SOURCE)' != '' ">$(NuGetPackagesArchiveProject)/Nuget.config</LZMANuGetConfigFilePath>
|
||||
<LZMANuGetConfigFilePath Condition=" '$(LZMANuGetConfigFilePath)' == '' ">$(RepoRoot)/NuGet.Config</LZMANuGetConfigFilePath>
|
||||
<ToolsOutputDirectory>$(BaseOutputDirectory)/tools</ToolsOutputDirectory>
|
||||
<ArchiverDll>$(ToolsOutputDirectory)/Archiver.dll</ArchiverDll>
|
||||
<FinalArchive>$(SdkOutputDirectory)/nuGetPackagesArchive.lzma</FinalArchive>
|
||||
|
@ -96,6 +97,7 @@
|
|||
|
||||
<DotNetRestore ToolPath="$(OutputDirectory)"
|
||||
Packages="$(NuGetPackagesArchiveFolder)"
|
||||
ConfigFile="$(LZMANuGetConfigFilePath)"
|
||||
SkipInvalidConfigurations="True"
|
||||
WorkingDirectory="$(NuGetPackagesArchiveProject)/Console" />
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ using NuGet.Common;
|
|||
|
||||
namespace Microsoft.DotNet.Configurer
|
||||
{
|
||||
public class CLIFallbackFolderPathCalculator
|
||||
public class CliFallbackFolderPathCalculator
|
||||
{
|
||||
public string CLIFallbackFolderPath
|
||||
public string CliFallbackFolderPath
|
||||
{
|
||||
get
|
||||
{
|
|
@ -5,6 +5,6 @@ namespace Microsoft.DotNet.Configurer
|
|||
{
|
||||
public interface INuGetConfig
|
||||
{
|
||||
void AddCLIFallbackFolder(string fallbackFolderPath);
|
||||
void AddCliFallbackFolder(string fallbackFolderPath);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,13 +18,13 @@ namespace Microsoft.DotNet.Configurer
|
|||
|
||||
private readonly INuGetConfig _nuGetConfig;
|
||||
|
||||
private readonly CLIFallbackFolderPathCalculator _cliFallbackFolderPathCalculator;
|
||||
private readonly CliFallbackFolderPathCalculator _cliFallbackFolderPathCalculator;
|
||||
|
||||
public NuGetCachePrimer(
|
||||
INuGetPackagesArchiver nugetPackagesArchiver,
|
||||
INuGetCacheSentinel nuGetCacheSentinel,
|
||||
INuGetConfig nuGetConfig,
|
||||
CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
: this(nugetPackagesArchiver,
|
||||
nuGetCacheSentinel,
|
||||
nuGetConfig,
|
||||
|
@ -37,7 +37,7 @@ namespace Microsoft.DotNet.Configurer
|
|||
INuGetPackagesArchiver nugetPackagesArchiver,
|
||||
INuGetCacheSentinel nuGetCacheSentinel,
|
||||
INuGetConfig nuGetConfig,
|
||||
CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator,
|
||||
CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator,
|
||||
IFile file)
|
||||
{
|
||||
_nugetPackagesArchiver = nugetPackagesArchiver;
|
||||
|
@ -58,9 +58,9 @@ namespace Microsoft.DotNet.Configurer
|
|||
return;
|
||||
}
|
||||
|
||||
var nuGetFallbackFolder = _cliFallbackFolderPathCalculator.CLIFallbackFolderPath;
|
||||
var nuGetFallbackFolder = _cliFallbackFolderPathCalculator.CliFallbackFolderPath;
|
||||
|
||||
_nuGetConfig.AddCLIFallbackFolder(nuGetFallbackFolder);
|
||||
_nuGetConfig.AddCliFallbackFolder(nuGetFallbackFolder);
|
||||
|
||||
_nugetPackagesArchiver.ExtractArchive(nuGetFallbackFolder);
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ namespace Microsoft.DotNet.Configurer
|
|||
|
||||
private Stream InProgressSentinel { get; set; }
|
||||
|
||||
public NuGetCacheSentinel(CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator) :
|
||||
this(cliFallbackFolderPathCalculator.CLIFallbackFolderPath, FileSystemWrapper.Default.File)
|
||||
public NuGetCacheSentinel(CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator) :
|
||||
this(cliFallbackFolderPathCalculator.CliFallbackFolderPath, FileSystemWrapper.Default.File)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Microsoft.DotNet.Configurer
|
|||
|
||||
private ISettings _settings;
|
||||
|
||||
public NuGetConfig(CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
public NuGetConfig(CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
{
|
||||
_settings = new Settings(cliFallbackFolderPathCalculator.NuGetUserSettingsDirectory);
|
||||
}
|
||||
|
@ -23,15 +23,15 @@ namespace Microsoft.DotNet.Configurer
|
|||
_settings = settings;
|
||||
}
|
||||
|
||||
public void AddCLIFallbackFolder(string fallbackFolderPath)
|
||||
public void AddCliFallbackFolder(string fallbackFolderPath)
|
||||
{
|
||||
if (!IsCLIFallbackFolderSet(fallbackFolderPath))
|
||||
if (!IsCliFallbackFolderSet(fallbackFolderPath))
|
||||
{
|
||||
_settings.SetValue(FallbackPackageFolders, "CLIFallbackFolder", fallbackFolderPath);
|
||||
_settings.SetValue(FallbackPackageFolders, "CliFallbackFolder", fallbackFolderPath);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsCLIFallbackFolderSet(string fallbackFolderPath)
|
||||
private bool IsCliFallbackFolderSet(string fallbackFolderPath)
|
||||
{
|
||||
return _settings.GetSettingValues(FallbackPackageFolders).Any(s => s.Value == fallbackFolderPath);
|
||||
}
|
||||
|
|
|
@ -110,6 +110,7 @@ namespace Microsoft.DotNet.TestFramework
|
|||
var content = @"<?xml version=""1.0"" encoding=""utf-8""?>
|
||||
<configuration>
|
||||
<packageSources>
|
||||
<add key=""dotnet-core"" value=""https://dotnet.myget.org/F/dotnet-core/api/v3/index.json"" />
|
||||
<add key=""test-packages"" value=""$fullpath$"" />
|
||||
</packageSources>
|
||||
</configuration>";
|
||||
|
|
|
@ -79,7 +79,7 @@ namespace Microsoft.DotNet.Cli
|
|||
var success = true;
|
||||
var command = string.Empty;
|
||||
var lastArg = 0;
|
||||
var cliFallbackFolderPathCalculator = new CLIFallbackFolderPathCalculator();
|
||||
var cliFallbackFolderPathCalculator = new CliFallbackFolderPathCalculator();
|
||||
using (INuGetCacheSentinel nugetCacheSentinel = new NuGetCacheSentinel(cliFallbackFolderPathCalculator))
|
||||
{
|
||||
for (; lastArg < args.Length; lastArg++)
|
||||
|
@ -168,7 +168,7 @@ namespace Microsoft.DotNet.Cli
|
|||
|
||||
private static void ConfigureDotNetForFirstTimeUse(
|
||||
INuGetCacheSentinel nugetCacheSentinel,
|
||||
CLIFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
|
||||
{
|
||||
using (PerfTrace.Current.CaptureTiming())
|
||||
{
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Microsoft.DotNet.Tools.MSBuild
|
|||
{
|
||||
public sealed class MSBuildLogger : Logger
|
||||
{
|
||||
private readonly INuGetCacheSentinel _sentinel = new NuGetCacheSentinel(new CLIFallbackFolderPathCalculator());
|
||||
private readonly INuGetCacheSentinel _sentinel = new NuGetCacheSentinel(new CliFallbackFolderPathCalculator());
|
||||
private readonly ITelemetry _telemetry;
|
||||
|
||||
public MSBuildLogger()
|
||||
|
|
|
@ -342,7 +342,8 @@ namespace Microsoft.DotNet.Tests
|
|||
|
||||
var testInstance = TestAssets.Get("AppWithFallbackFolderToolDependency")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
.WithSourceFiles()
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages);
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
var fallbackFolder = Path.Combine(testProjectDirectory, "fallbackFolder");
|
||||
|
||||
|
@ -378,13 +379,14 @@ namespace Microsoft.DotNet.Tests
|
|||
}
|
||||
|
||||
[Fact]
|
||||
public void ItXXXWhenTheToolDllIsNotFound()
|
||||
public void ItShowsAnErrorWhenTheToolDllIsNotFound()
|
||||
{
|
||||
var projectToolsCommandResolver = SetupProjectToolsCommandResolver();
|
||||
|
||||
var testInstance = TestAssets.Get("AppWithFallbackFolderToolDependency")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles();
|
||||
.WithSourceFiles()
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages);
|
||||
var testProjectDirectory = testInstance.Root.FullName;
|
||||
var fallbackFolder = Path.Combine(testProjectDirectory, "fallbackFolder");
|
||||
|
||||
|
@ -415,9 +417,10 @@ namespace Microsoft.DotNet.Tests
|
|||
|
||||
private void PopulateFallbackFolder(string testProjectDirectory, string fallbackFolder)
|
||||
{
|
||||
var nugetConfigPath = Path.Combine(testProjectDirectory, "NuGet.Config");
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute($"--packages {fallbackFolder}")
|
||||
.Execute($"--configfile {nugetConfigPath} --packages {fallbackFolder}")
|
||||
.Should()
|
||||
.Pass();
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
private Mock<INuGetPackagesArchiver> _nugetPackagesArchiverMock;
|
||||
private Mock<INuGetCacheSentinel> _nugetCacheSentinel;
|
||||
private Mock<INuGetConfig> _nugetConfigMock;
|
||||
private CLIFallbackFolderPathCalculator _cliFallbackFolderPathCalculator;
|
||||
private CliFallbackFolderPathCalculator _cliFallbackFolderPathCalculator;
|
||||
|
||||
public GivenANuGetCachePrimer()
|
||||
{
|
||||
|
@ -42,7 +42,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
|
||||
_nugetConfigMock = new Mock<INuGetConfig>();
|
||||
|
||||
_cliFallbackFolderPathCalculator = new CLIFallbackFolderPathCalculator();
|
||||
_cliFallbackFolderPathCalculator = new CliFallbackFolderPathCalculator();
|
||||
|
||||
var nugetCachePrimer = new NuGetCachePrimer(
|
||||
_nugetPackagesArchiverMock.Object,
|
||||
|
@ -79,7 +79,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
public void It_adds_the_fallback_folder_to_NuGet_Config()
|
||||
{
|
||||
_nugetConfigMock.Verify(n =>
|
||||
n.AddCLIFallbackFolder(_cliFallbackFolderPathCalculator.CLIFallbackFolderPath),
|
||||
n.AddCliFallbackFolder(_cliFallbackFolderPathCalculator.CliFallbackFolderPath),
|
||||
Times.Exactly(1));
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
public void It_extracts_the_archive_to_the_fallback_folder()
|
||||
{
|
||||
_nugetPackagesArchiverMock.Verify(n =>
|
||||
n.ExtractArchive(_cliFallbackFolderPathCalculator.CLIFallbackFolderPath),
|
||||
n.ExtractArchive(_cliFallbackFolderPathCalculator.CliFallbackFolderPath),
|
||||
Times.Exactly(1));
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
.Setup(s => s.GetSettingValues(NuGetConfig.FallbackPackageFolders, false))
|
||||
.Returns(new List<SettingValue>()
|
||||
{
|
||||
new SettingValue("CLIFallbackFolder", PathToFallbackFolderAlreadySet, false)
|
||||
new SettingValue("CliFallbackFolder", PathToFallbackFolderAlreadySet, false)
|
||||
});
|
||||
|
||||
_nugetConfig = new NuGetConfig(_settingsMock.Object);
|
||||
|
@ -33,20 +33,20 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
|||
public void ItAddsACliFallbackFolderIfOneIsNotPresentAlready()
|
||||
{
|
||||
const string FallbackFolderNotAlreadySet = "some path not already set";
|
||||
_nugetConfig.AddCLIFallbackFolder(FallbackFolderNotAlreadySet);
|
||||
_nugetConfig.AddCliFallbackFolder(FallbackFolderNotAlreadySet);
|
||||
|
||||
_settingsMock.Verify(s =>
|
||||
s.SetValue(NuGetConfig.FallbackPackageFolders, "CLIFallbackFolder", FallbackFolderNotAlreadySet),
|
||||
s.SetValue(NuGetConfig.FallbackPackageFolders, "CliFallbackFolder", FallbackFolderNotAlreadySet),
|
||||
Times.Exactly(1));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItDoesNotAddTheCliFallbackFolderIfItIsAlreadyPresent()
|
||||
{
|
||||
_nugetConfig.AddCLIFallbackFolder(PathToFallbackFolderAlreadySet);
|
||||
_nugetConfig.AddCliFallbackFolder(PathToFallbackFolderAlreadySet);
|
||||
|
||||
_settingsMock.Verify(s =>
|
||||
s.SetValue(NuGetConfig.FallbackPackageFolders, "CLIFallbackFolder", PathToFallbackFolderAlreadySet),
|
||||
s.SetValue(NuGetConfig.FallbackPackageFolders, "CliFallbackFolder", PathToFallbackFolderAlreadySet),
|
||||
Times.Never);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,8 @@ namespace Microsoft.DotNet.Restore.Tests
|
|||
{
|
||||
public class GivenThatIWantToRestoreApp : TestBase
|
||||
{
|
||||
private static string RepoRootNuGetConfig = Path.Combine(RepoDirectoriesProvider.RepoRoot, "NuGet.Config");
|
||||
|
||||
[Fact]
|
||||
public void ItRestoresAppToSpecificDirectory()
|
||||
{
|
||||
|
@ -29,7 +31,7 @@ namespace Microsoft.DotNet.Restore.Tests
|
|||
.Should()
|
||||
.Pass();
|
||||
|
||||
string args = $"--packages \"{dir}\"";
|
||||
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\"";
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput(args)
|
||||
|
@ -56,7 +58,7 @@ namespace Microsoft.DotNet.Restore.Tests
|
|||
.Should()
|
||||
.Pass();
|
||||
|
||||
string args = $"--packages \"{dir}\"";
|
||||
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\"";
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput(args)
|
||||
|
@ -76,7 +78,7 @@ namespace Microsoft.DotNet.Restore.Tests
|
|||
string dir = "pkgs";
|
||||
string fullPath = Path.GetFullPath(Path.Combine(rootPath, dir));
|
||||
|
||||
string args = $"--packages \"{dir}\"";
|
||||
string args = $"--configfile {RepoRootNuGetConfig} --packages \"{dir}\"";
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(rootPath)
|
||||
.ExecuteWithCapturedOutput(args)
|
||||
|
|
Loading…
Reference in a new issue