diff --git a/build/common.project.props b/build/common.project.props index 87fca675a27..782d5ddd167 100644 --- a/build/common.project.props +++ b/build/common.project.props @@ -15,8 +15,8 @@ net472 netcoreapp2.1 netcoreapp2.1 - netcoreapp2.1;netcoreapp5.0 - netcoreapp5.0 + netcoreapp2.1;netcoreapp5.0 + netcoreapp3.1;netcoreapp5.0 netstandard2.0 $(NETFXTargetFramework);$(NETCoreTargetFrameworks) $(NETFXTargetFramework);$(NetStandardVersion) diff --git a/build/config.props b/build/config.props index 00a77aa4437..fc44c660e88 100644 --- a/build/config.props +++ b/build/config.props @@ -16,11 +16,11 @@ 7 0 $(MajorNuGetVersion).$(MinorNuGetVersion).$(PatchNuGetVersion) - + preview.2 - + @@ -28,23 +28,23 @@ false - + $([MSBuild]::Add(11, $(MajorNuGetVersion))) master int.$(VsTargetBranch) - + rel/d$(VsTargetMajorVersion).$(MinorNuGetVersion) int.d$(VsTargetMajorVersion).$(MinorNuGetVersion) - + true - master + master;3.1 master - "master 5.0.100-preview.3.20216.6" + "master 5.0.100-preview.3.20216.6" $(OverrideCliBranchForTesting) master $(OverrideCliTargetBranches) diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Dotnet.Integration.Test.csproj b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Dotnet.Integration.Test.csproj index 62dd434cd28..fbc8341d348 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Dotnet.Integration.Test.csproj +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Dotnet.Integration.Test.csproj @@ -1,14 +1,13 @@ - + true - true - $(NETCoreTargetFrameworks) + $(NETCoreTestTargetFrameworks) true Integration tests for NuGet-powered dotnet CLI commands such as pack/restore/list package and dotnet nuget. diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetListPackageTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetListPackageTests.cs index 8cad24f7bb5..b6fa9ecbd5f 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetListPackageTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetListPackageTests.cs @@ -31,7 +31,7 @@ public DotnetListPackageTests(MsbuildIntegrationTestFixture fixture) [PlatformFact(Platform.Windows)] public async Task DotnetListPackage_Succeed() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46"); @@ -61,7 +61,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [PlatformFact(Platform.Windows)] public async Task DotnetListPackage_NoRestore_Fail() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46"); @@ -88,7 +88,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [PlatformFact(Platform.Windows)] public async Task DotnetListPackage_Transitive() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46"); @@ -134,7 +134,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [InlineData("--framework net46", "net46", "net451")] public async Task DotnetListPackage_FrameworkSpecific_Success(string args, string shouldInclude, string shouldntInclude) { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46;net451"); @@ -171,7 +171,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [PlatformFact(Platform.Windows)] public async Task DotnetListPackage_InvalidFramework_Fail() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46"); @@ -204,7 +204,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [PlatformFact(Platform.Windows)] public void DotnetListPackage_DeprecatedAndOutdated_Fail() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46"); @@ -222,7 +222,7 @@ public void DotnetListPackage_DeprecatedAndOutdated_Fail() [PlatformFact(Platform.Windows)] public async Task DotnetListPackage_ShowFrameworksOnly_SDK() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net461"); @@ -273,7 +273,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [InlineData("1.0.0", "--highest-minor --include-prerelease", "1.10.0-beta")] public async Task DotnetListPackage_Outdated_Succeed(string currentVersion, string args, string expectedVersion) { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net472"); var versions = new List { "1.0.0-beta", "1.0.0", "1.0.9", "1.0.10-beta", "1.9.0", "1.10.0-beta", "2.1.0", "2.2.0-beta" }; @@ -312,7 +312,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( public void DotnetListPackage_ProjectReference_Succeeds(bool includeTransitive, bool outdated) { // Arrange - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject("ProjectA", pathContext, "net46"); var projectB = XPlatTestUtils.CreateProject("ProjectB", pathContext, "net46"); @@ -359,7 +359,7 @@ public void DotnetListPackage_ProjectReference_Succeeds(bool includeTransitive, public async Task DotnetListPackage_OutdatedWithNoVersionsFound_Succeeds() { // Arrange - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject("ProjectA", pathContext, "net46"); var packageX = XPlatTestUtils.CreatePackage(packageId: "packageX", packageVersion: "1.0.0"); @@ -397,7 +397,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( [PlatformFact(Platform.Windows)] public async Task DotnetListPackage_ProjectWithInitialTargets_Succeeds() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _fixture.CreateSimpleTestPathContext()) { var projectA = XPlatTestUtils.CreateProject(ProjectName, pathContext, "net46"); diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetRestoreTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetRestoreTests.cs index e5c180abedd..7f28200525d 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetRestoreTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetRestoreTests.cs @@ -30,7 +30,7 @@ public DotnetRestoreTests(MsbuildIntegrationTestFixture fixture) [PlatformFact(Platform.Windows)] public void DotnetRestore_SolutionRestoreVerifySolutionDirPassedToProjects() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { _msbuildFixture.CreateDotnetNewProject(pathContext.SolutionRoot, "proj"); @@ -85,19 +85,18 @@ public void DotnetRestore_SolutionRestoreVerifySolutionDirPassedToProjects() [PlatformFact(Platform.Windows)] public void DotnetRestore_WithAuthorSignedPackage_Succeeds() { - using (var packageSourceDirectory = TestDirectory.Create()) - using (var testDirectory = TestDirectory.Create()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { - var packageFile = new FileInfo(Path.Combine(packageSourceDirectory.Path, "TestPackage.AuthorSigned.1.0.0.nupkg")); + var packageFile = new FileInfo(Path.Combine(pathContext.PackageSource, "TestPackage.AuthorSigned.1.0.0.nupkg")); var package = GetResource(packageFile.Name); File.WriteAllBytes(packageFile.FullName, package); var projectName = "ClassLibrary1"; - var workingDirectory = Path.Combine(testDirectory, projectName); + var workingDirectory = Path.Combine(pathContext.SolutionRoot, projectName); var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj"); - _msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib"); + _msbuildFixture.CreateDotnetNewProject(pathContext.SolutionRoot, projectName, " classlib"); using (var stream = File.Open(projectFile, FileMode.Open, FileAccess.ReadWrite)) { @@ -118,16 +117,14 @@ public void DotnetRestore_WithAuthorSignedPackage_Succeeds() ProjectFileUtils.WriteXmlToFile(xml, stream); } - var args = $"--source \"{packageSourceDirectory.Path}\" "; - - _msbuildFixture.RestoreProject(workingDirectory, projectName, args); + _msbuildFixture.RestoreProject(workingDirectory, projectName, args: string.Empty); } } [PlatformFact(Platform.Windows)] public async Task DotnetRestore_OneLinePerRestore() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { var testDirectory = pathContext.SolutionRoot; var pkgX = new SimpleTestPackageContext("x", "1.0.0"); @@ -205,7 +202,7 @@ public async Task DotnetRestore_OneLinePerRestore() [PlatformFact(Platform.Windows)] public async Task DotnetRestore_ProjectMovedDoesNotRunRestore() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { var tfm = "net472"; var testDirectory = pathContext.SolutionRoot; @@ -264,7 +261,7 @@ public async Task DotnetRestore_ProjectMovedDoesNotRunRestore() [PlatformFact(Platform.Windows)] public void DotnetRestore_PackageDownloadSupported_IsSet() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { _msbuildFixture.CreateDotnetNewProject(pathContext.SolutionRoot, "proj"); @@ -291,7 +288,7 @@ public void DotnetRestore_PackageDownloadSupported_IsSet() [PlatformFact(Platform.Windows)] public async Task DotnetRestore_LockedMode_NewProjectOutOfBox() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { // Set up solution, and project @@ -363,7 +360,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async( public async Task DotnetRestore_VerifyPerProjectConfigSourcesAreUsedForChildProjectsWithoutSolutionAsync() { // Arrange - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { var solution = new SimpleTestSolutionContext(pathContext.SolutionRoot); var projects = new Dictionary(); @@ -463,7 +460,7 @@ public async Task DotnetRestore_VerifyPerProjectConfigSourcesAreUsedForChildProj public async Task DotnetRestore_VerifyPerProjectConfigSourcesAreUsedForChildProjectsWithSolutionAsync() { // Arrange - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { var projects = new Dictionary(); var sources = new List(); @@ -562,7 +559,7 @@ public async Task DotnetRestore_VerifyPerProjectConfigSourcesAreUsedForChildProj [PlatformFact(Platform.Windows)] public async Task DotnetRestore_PackageReferenceWithAliases_ReflectedInTheAssetsFile() { - using (var pathContext = new SimpleTestPathContext()) + using (var pathContext = _msbuildFixture.CreateSimpleTestPathContext()) { // Set up solution, and project var solution = new SimpleTestSolutionContext(pathContext.SolutionRoot); diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetSourcesTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetSourcesTests.cs index d766c5004f8..e980c0ae60c 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetSourcesTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetSourcesTests.cs @@ -151,7 +151,7 @@ public void Sources_WhenAddingSourceWithCredentialsInClearText_CredentialsWereAd public void Sources_WhenAddingSourceWithCredentialsToUserConfigFile_CredentialsWereAddedAndEncryptedInUserConfigFile() { // Arrange - using (var configFileDirectory = TestDirectory.Create()) + using (var configFileDirectory = _fixture.CreateTestDirectory()) { var configFileName = "nuget.config"; var configFilePath = Path.Combine(configFileDirectory, configFileName); @@ -182,7 +182,7 @@ public void Sources_WhenAddingSourceWithCredentialsToUserConfigFile_CredentialsW var result = _fixture.RunDotnet(configFileDirectory, string.Join(" ", args), ignoreExitCode: true); // Assert - Assert.True(result.Success); + Assert.True(result.Success, result.AllOutput); var settings = Settings.LoadDefaultSettings( configFileDirectory, @@ -217,7 +217,7 @@ private static void CreateXmlFile(string configFilePath, string nugetConfigStrin public void Sources_WhenEnablingADisabledSource_SourceBecameEnabled() { // Arrange - using (var configFileDirectory = TestDirectory.Create()) + using (var configFileDirectory = _fixture.CreateTestDirectory()) { var configFileName = "nuget.config"; var configFilePath = Path.Combine(configFileDirectory, configFileName); @@ -260,7 +260,7 @@ public void Sources_WhenEnablingADisabledSource_SourceBecameEnabled() Assert.False(source.IsEnabled); // Main Act - var result = _fixture.RunDotnet(Directory.GetCurrentDirectory(), string.Join(" ", args), ignoreExitCode: true); + var result = _fixture.RunDotnet(configFileDirectory, string.Join(" ", args), ignoreExitCode: true); // Assert Assert.True(result.ExitCode == 0); @@ -293,7 +293,7 @@ public void Sources_WhenEnablingADisabledSource_SourceBecameEnabled() public void Sources_WhenDisablingAnEnabledSource_SourceBecameDisabled() { // Arrange - using (var configFileDirectory = TestDirectory.Create()) + using (var configFileDirectory = _fixture.CreateTestDirectory()) { var configFileName = "nuget.config"; var configFilePath = Path.Combine(configFileDirectory, configFileName); @@ -333,7 +333,7 @@ public void Sources_WhenDisablingAnEnabledSource_SourceBecameDisabled() Assert.True(source.IsEnabled); // Main Act - var result = _fixture.RunDotnet(Directory.GetCurrentDirectory(), string.Join(" ", args), ignoreExitCode: true); + var result = _fixture.RunDotnet(configFileDirectory, string.Join(" ", args), ignoreExitCode: true); // Assert Assert.True(result.ExitCode == 0); @@ -414,40 +414,43 @@ public void TestVerbosityQuiet_DoesNotShowInfoMessages() /// The nuget.exe command name to verify, without "nuget.exe" at the beginning public void TestCommandInvalidArguments(string command, int badCommandIndex) { - // Act - var result = _fixture.RunDotnet(Directory.GetCurrentDirectory(), command, ignoreExitCode: true); + using (var testDirectory = _fixture.CreateTestDirectory()) + { + // Act + var result = _fixture.RunDotnet(testDirectory, command, ignoreExitCode: true); - var commandSplit = command.Split(' '); + var commandSplit = command.Split(' '); - // Break the test if no proper command is found - if (commandSplit.Length < 1 || string.IsNullOrEmpty(commandSplit[0])) - Assert.True(false, "command not found"); + // Break the test if no proper command is found + if (commandSplit.Length < 1 || string.IsNullOrEmpty(commandSplit[0])) + Assert.True(false, "command not found"); - // 0th - "nuget" - // 1st - "source" - // 2nd - action - // 3rd - nextParam - string badCommand = commandSplit[badCommandIndex]; + // 0th - "nuget" + // 1st - "source" + // 2nd - action + // 3rd - nextParam + string badCommand = commandSplit[badCommandIndex]; - // Assert command - Assert.Contains("'" + badCommand + "'", result.Output, StringComparison.InvariantCultureIgnoreCase); + // Assert command + Assert.Contains("'" + badCommand + "'", result.Output, StringComparison.InvariantCultureIgnoreCase); - // Assert invalid argument message - string invalidMessage; - if (badCommand.StartsWith("-")) - { - invalidMessage = "error: Unrecognized option"; - } - else - { - invalidMessage = "error: Unrecognized command"; - } + // Assert invalid argument message + string invalidMessage; + if (badCommand.StartsWith("-")) + { + invalidMessage = "error: Unrecognized option"; + } + else + { + invalidMessage = "error: Unrecognized command"; + } - // Verify Exit code - VerifyResultFailure(result, invalidMessage); - // Verify traits of help message in stdout - Assert.Contains("Specify --help for a list of available options and commands.", result.Output); + // Verify Exit code + VerifyResultFailure(result, invalidMessage); + // Verify traits of help message in stdout + Assert.Contains("Specify --help for a list of available options and commands.", result.Output); + } } /// diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs index 0a08d211672..dd6d7c2c011 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/DotnetToolTests.cs @@ -7,7 +7,6 @@ using System.Reflection; using System.Threading.Tasks; using NuGet.Common; -using NuGet.Frameworks; using NuGet.Packaging.Core; using NuGet.ProjectModel; using NuGet.Test.Utility; @@ -31,7 +30,7 @@ public DotnetToolTests(MsbuildIntegrationTestFixture fixture) [InlineData("netcoreapp1.0")] public void DotnetToolTests_NoPackageReferenceToolRestore_ThrowsError(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -56,7 +55,7 @@ public void DotnetToolTests_NoPackageReferenceToolRestore_ThrowsError(string tfm [InlineData("netcoreapp1.0")] public void DotnetToolTests_RegularDependencyPackageWithDependenciesToolRestore_ThrowsError(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -84,7 +83,7 @@ public void DotnetToolTests_RegularDependencyPackageWithDependenciesToolRestore_ [InlineData("netcoreapp2.0")] public async Task DotnetToolTests_BasicDotnetToolRestore_SucceedsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -130,7 +129,7 @@ public async Task DotnetToolTests_BasicDotnetToolRestore_SucceedsAsync(string tf [InlineData("netcoreapp2.0")] public async Task DotnetToolTests_MismatchedRID_FailsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -167,7 +166,7 @@ public async Task DotnetToolTests_MismatchedRID_FailsAsync(string tfm) [InlineData("netcoreapp2.0")] public async Task DotnetToolTests_BasicDotnetToolRestore_WithJsonCompatibleAssets_SucceedsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -216,7 +215,7 @@ public async Task DotnetToolTests_BasicDotnetToolRestore_WithJsonCompatibleAsset [InlineData("netcoreapp2.0", "any", "win-x86")] public async Task DotnetToolTests_PackageWithRuntimeJson_RuntimeIdentifierAny_SucceedsAsync(string tfm, string packageRID, string projectRID) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -262,7 +261,7 @@ public async Task DotnetToolTests_PackageWithRuntimeJson_RuntimeIdentifierAny_Su [InlineData("netcoreapp1.0")] public async Task DotnetToolTests_RegularDependencyAndToolPackageWithDependenciesToolRestore_ThrowsErrorAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -306,7 +305,7 @@ public async Task DotnetToolTests_RegularDependencyAndToolPackageWithDependencie [InlineData("netcoreapp1.0", "any", "win7-x64")] public async Task DotnetToolTests_ToolWithPlatformPackage_SucceedsAsync(string tfm, string packageRid, string projectRid) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -362,7 +361,7 @@ public async Task DotnetToolTests_ToolWithPlatformPackage_SucceedsAsync(string t [InlineData("netcoreapp2.0")] public async Task DotnetToolTests_ToolPackageWithIncompatibleToolsAssets_FailsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -401,7 +400,7 @@ public async Task DotnetToolTests_ToolPackageWithIncompatibleToolsAssets_FailsAs [InlineData("netcoreapp2.0")] public async Task DotnetToolTests_ToolsPackageWithExtraPackageTypes_FailsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -437,7 +436,7 @@ public async Task DotnetToolTests_ToolsPackageWithExtraPackageTypes_FailsAsync(s [InlineData("netcoreapp2.0")] public async Task DotnetToolTests_BasicDotnetToolRestoreWithNestedValues_SucceedsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -484,7 +483,7 @@ public async Task DotnetToolTests_BasicDotnetToolRestoreWithNestedValues_Succeed [InlineData("netcoreapp1.0")] public async Task DotnetToolTests_AutoreferencedDependencyAndToolPackagToolRestore_SucceedsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -537,7 +536,7 @@ public async Task DotnetToolTests_AutoreferencedDependencyAndToolPackagToolResto [InlineData("netcoreapp1.0")] public async Task DotnetToolTests_AutoreferencedDependencyRegularDependencyAndToolPackagToolRestore_ThrowsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -589,7 +588,7 @@ public async Task DotnetToolTests_AutoreferencedDependencyRegularDependencyAndTo [InlineData("netcoreapp1.0")] public async Task DotnetToolTests_ToolPackageAndPlatformsPackageAnyRID_SucceedsAsync(string tfm) { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var projectName = "ToolRestoreProject"; var workingDirectory = Path.Combine(testDirectory, projectName); @@ -641,7 +640,7 @@ public async Task DotnetToolTests_ToolPackageAndPlatformsPackageAnyRID_SucceedsA [PlatformFact(Platform.Windows)] public async Task DotnetToolTests_IncompatibleAutorefPackageAndToolsPackageAsync() { - using (var testDirectory = TestDirectory.Create()) + using (var testDirectory = _msbuildFixture.CreateTestDirectory()) { var tfm = "netcoreapp1.0"; var incompatibletfm = "netcoreapp2.0"; diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuildIntegrationTestFixture.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuildIntegrationTestFixture.cs index 71655f023a0..de613e01794 100644 --- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuildIntegrationTestFixture.cs +++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/MsbuildIntegrationTestFixture.cs @@ -9,11 +9,15 @@ using System.Reflection; using System.Text; using System.Threading; +using Dotnet.Integration.Test.Utils; using Newtonsoft.Json.Linq; +using NuGet.Commands; using NuGet.Common; +using NuGet.Frameworks; using NuGet.Packaging.Core; using NuGet.Protocol; using NuGet.Test.Utility; +using NuGet.Versioning; using NuGet.XPlat.FuncTest; using Xunit; @@ -22,10 +26,11 @@ namespace Dotnet.Integration.Test public class MsbuildIntegrationTestFixture : IDisposable { private readonly TestDirectory _cliDirectory; - private readonly TestDirectory _templateDirectory; + private readonly SimpleTestPathContext _templateDirectory; private readonly string _dotnetCli = DotnetCliUtil.GetDotnetCli(); internal readonly string TestDotnetCli; internal readonly string MsBuildSdksPath; + internal string SdkVersion { get; private set; } private readonly Dictionary _processEnvVars = new Dictionary(); public MsbuildIntegrationTestFixture() @@ -34,18 +39,24 @@ public MsbuildIntegrationTestFixture() var dotnetExecutableName = RuntimeEnvironmentHelper.IsWindows ? "dotnet.exe" : "dotnet"; TestDotnetCli = Path.Combine(_cliDirectory, dotnetExecutableName); - var sdkPaths = Directory.GetDirectories(Path.Combine(_cliDirectory, "sdk")); + var sdkPath = Directory.GetDirectories(Path.Combine(_cliDirectory, "sdk")).Single(); +#if NETCOREAPP5_0 // TODO - remove when shipping. See https://github.com/NuGet/Home/issues/8508 - // const string dotnetMajorVersion = "3."; - const string dotnetMajorVersion = "5."; - PatchSDKWithCryptographyDlls(dotnetMajorVersion, sdkPaths); + PatchSDKWithCryptographyDlls(sdkPath); +#endif - MsBuildSdksPath = Path.Combine( - sdkPaths.Where(path => path.Split(Path.DirectorySeparatorChar).Last().StartsWith(dotnetMajorVersion)).First() - , "Sdks"); + MsBuildSdksPath = Path.Combine(sdkPath, "Sdks"); - _templateDirectory = TestDirectory.Create(); + _templateDirectory = new SimpleTestPathContext(); + WriteGlobalJson(_templateDirectory.WorkingDirectory); + var addSourceArgs = new AddSourceArgs() + { + Configfile = _templateDirectory.NuGetConfig, + Name = "nuget.org", + Source = "https://api.nuget.org/v3/index.json" + }; + AddSourceRunner.Run(addSourceArgs, () => NullLogger.Instance); _processEnvVars.Add("MSBuildSDKsPath", MsBuildSdksPath); _processEnvVars.Add("UseSharedCompilation", "false"); @@ -54,7 +65,7 @@ public MsbuildIntegrationTestFixture() } /// - /// Creates a new dotnet project of the specified type. Note that restore/build are not run when this command is invoked. + /// Creates a new dotnet project of the specified type. Note that restore/build are not run when this command is invoked. /// That is because the project generation is cached. /// internal void CreateDotnetNewProject(string solutionRoot, string projectName, string args = "console", int timeOut = 60000) @@ -65,7 +76,7 @@ internal void CreateDotnetNewProject(string solutionRoot, string projectName, st { Directory.CreateDirectory(workingDirectory); } - var templateDirectory = new DirectoryInfo(Path.Combine(_templateDirectory.Path, args)); + var templateDirectory = new DirectoryInfo(Path.Combine(_templateDirectory.SolutionRoot, args)); if (!templateDirectory.Exists) { @@ -79,8 +90,8 @@ internal void CreateDotnetNewProject(string solutionRoot, string projectName, st environmentVariables: _processEnvVars); Assert.True(result.Success, $"Creating project failed with following log information :\n {result.AllOutput}"); Assert.True(string.IsNullOrWhiteSpace(result.Errors), $"Creating project failed with following message in error stream :\n {result.AllOutput}"); - // Delete the obj directory because it contains assets generated by running restore at dotnet new