diff --git a/build/DotNetSdkTestVersions.txt b/build/DotNetSdkTestVersions.txt index 14d40d5aa45..23c5a5c6e64 100644 --- a/build/DotNetSdkTestVersions.txt +++ b/build/DotNetSdkTestVersions.txt @@ -1,3 +1,3 @@ # Each line represents arguments for the .NET SDK installer script (https://learn.microsoft.com/dotnet/core/tools/dotnet-install-script) --Channel 9.0.1xx -Quality daily +-Channel 9.0.2xx -Quality daily -Channel 8.0 -Runtime dotnet diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetIntegrationTestFixture.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetIntegrationTestFixture.cs index 728f212a47f..0a81ae1b011 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetIntegrationTestFixture.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetIntegrationTestFixture.cs @@ -227,7 +227,7 @@ internal CommandRunnerResult RunDotnetExpectSuccess(string workingDirectory, str /// The command-line arguments to pass to dotnet. /// An optional containing environment variables to use when executing the command. internal CommandRunnerResult RunDotnetExpectFailure(string workingDirectory, string args = "", IReadOnlyDictionary environmentVariables = null, ITestOutputHelper testOutputHelper = null) - => RunDotnet(workingDirectory, args, expectSuccess: false, environmentVariables); + => RunDotnet(workingDirectory, args, expectSuccess: false, environmentVariables, testOutputHelper); private CommandRunnerResult RunDotnet(string workingDirectory, string args = "", bool expectSuccess = true, IReadOnlyDictionary environmentVariables = null, ITestOutputHelper testOutputHelper = null) { diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetWhyTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetWhyTests.cs index 8ca1bec2cc4..8738430a195 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetWhyTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetWhyTests.cs @@ -9,6 +9,7 @@ using NuGet.Test.Utility; using NuGet.XPlat.FuncTest; using Xunit; +using Xunit.Abstractions; namespace Dotnet.Integration.Test { @@ -18,10 +19,12 @@ public class DotnetWhyTests private static readonly string ProjectName = "Test.Project.DotnetNugetWhy"; private readonly DotnetIntegrationTestFixture _testFixture; + private readonly ITestOutputHelper _testOutputHelper; - public DotnetWhyTests(DotnetIntegrationTestFixture testFixture) + public DotnetWhyTests(DotnetIntegrationTestFixture testFixture, ITestOutputHelper testOutputHelper) { _testFixture = testFixture; + _testOutputHelper = testOutputHelper; } [Fact] @@ -29,15 +32,14 @@ public async Task WhyCommand_ProjectHasTransitiveDependency_DependencyPathExists { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", projectFramework); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", Constants.ProjectTargetFramework); packageX.Dependencies.Add(packageY); - project.AddPackageToFramework(projectFramework, packageX); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -45,12 +47,12 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageY); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.Success, result.ExitCode); @@ -62,13 +64,12 @@ public async Task WhyCommand_ProjectHasNoDependencyOnTargetPackage_PathDoesNotEx { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - project.AddPackageToFramework(projectFramework, packageX); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); - var packageZ = XPlatTestUtils.CreatePackage("PackageZ", "1.0.0", projectFramework); + var packageZ = XPlatTestUtils.CreatePackage("PackageZ", "1.0.0", Constants.ProjectTargetFramework); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -76,12 +77,12 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageZ); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); string whyCommandArgs = $"nuget why {project.ProjectPath} {packageZ.Id}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.Success, result.ExitCode); @@ -93,15 +94,14 @@ public async Task WhyCommand_WithFrameworksOption_OptionParsedSuccessfully() { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", projectFramework); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", Constants.ProjectTargetFramework); packageX.Dependencies.Add(packageY); - project.AddPackageToFramework(projectFramework, packageX); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -109,12 +109,12 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageY); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); - string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id} --framework {projectFramework}"; + string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id} --framework {Constants.ProjectTargetFramework}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.Success, result.ExitCode); @@ -126,15 +126,14 @@ public async Task WhyCommand_WithFrameworksOptionAlias_OptionParsedSuccessfully( { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", projectFramework); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", Constants.ProjectTargetFramework); packageX.Dependencies.Add(packageY); - project.AddPackageToFramework(projectFramework, packageX); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -142,12 +141,12 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageY); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); - string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id} -f {projectFramework}"; + string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id} -f {Constants.ProjectTargetFramework}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.Success, result.ExitCode); @@ -163,25 +162,24 @@ public void WhyCommand_EmptyProjectArgument_Fails() string whyCommandArgs = $"nuget why"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectFailure(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectFailure(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.InvalidArguments, result.ExitCode); Assert.Contains($"Required argument missing for command: 'why'.", result.Errors); } - [Fact] + [Fact(Skip = "https://github.com/NuGet/Home/issues/14030")] public void WhyCommand_EmptyPackageArgument_Fails() { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); string whyCommandArgs = $"nuget why {project.ProjectPath}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectFailure(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectFailure(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.InvalidArguments, result.ExitCode); @@ -193,16 +191,15 @@ public async Task WhyCommand_InvalidFrameworksOption_WarnsCorrectly() { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; var inputFrameworksOption = "invalidFrameworkAlias"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", projectFramework); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", Constants.ProjectTargetFramework); packageX.Dependencies.Add(packageY); - project.AddPackageToFramework(projectFramework, packageX); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -210,12 +207,12 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageY); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); - string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id} -f {inputFrameworksOption} -f {projectFramework}"; + string whyCommandArgs = $"nuget why {project.ProjectPath} {packageY.Id} -f {inputFrameworksOption} -f {Constants.ProjectTargetFramework}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.Success, result.ExitCode); @@ -228,15 +225,14 @@ public async Task WhyCommand_DirectoryWithProject_HasTransitiveDependency_Depend { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", projectFramework); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", Constants.ProjectTargetFramework); packageX.Dependencies.Add(packageY); - project.AddPackageToFramework(projectFramework, packageX); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -244,13 +240,13 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageY); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); var projectDirectory = Path.GetDirectoryName(project.ProjectPath); string whyCommandArgs = $"nuget why {projectDirectory} {packageY.Id}"; // Act - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert Assert.Equal(ExitCodes.Success, result.ExitCode); @@ -262,15 +258,14 @@ public async Task WhyCommand_AssetsFileWithoutProject_Succeeds() { // Arrange var pathContext = new SimpleTestPathContext(); - var projectFramework = "net7.0"; - var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, projectFramework); + var project = XPlatTestUtils.CreateProject(ProjectName, pathContext, Constants.ProjectTargetFramework); - var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", projectFramework); - var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", projectFramework); + var packageX = XPlatTestUtils.CreatePackage("PackageX", "1.0.0", Constants.ProjectTargetFramework); + var packageY = XPlatTestUtils.CreatePackage("PackageY", "1.0.1", Constants.ProjectTargetFramework); packageX.Dependencies.Add(packageY); - project.AddPackageToFramework(projectFramework, packageX); + project.AddPackageToFramework(Constants.ProjectTargetFramework, packageX); await SimpleTestPackageUtility.CreatePackagesAsync( pathContext.PackageSource, @@ -278,13 +273,13 @@ await SimpleTestPackageUtility.CreatePackagesAsync( packageY); string addPackageCommandArgs = $"add {project.ProjectPath} package {packageX.Id}"; - CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs); + CommandRunnerResult addPackageResult = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, addPackageCommandArgs, testOutputHelper: _testOutputHelper); var assetsFile = Path.Combine(Path.GetDirectoryName(project.ProjectPath), "obj", "project.assets.json"); // Act string whyCommandArgs = $"nuget why {assetsFile} {packageY.Id}"; - CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectSuccess(pathContext.SolutionRoot, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert result.AllOutput.Should().Contain(packageX.Id); @@ -300,7 +295,7 @@ public void WhyCommand_EmptyJsonFile_OutputsError() // Act string whyCommandArgs = $"nuget why {jsonFilePath} packageId"; - CommandRunnerResult result = _testFixture.RunDotnetExpectFailure(testDirectory, whyCommandArgs); + CommandRunnerResult result = _testFixture.RunDotnetExpectFailure(testDirectory, whyCommandArgs, testOutputHelper: _testOutputHelper); // Assert result.AllOutput.Should().Contain("https://aka.ms/dotnet/nuget/why");