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 time.
- // These are not relevant when the project is renamed
+ // Delete the obj directory because it contains assets generated by running restore at dotnet new time.
+ // These are not relevant when the project is renamed
Directory.Delete(Path.Combine(templateDirectory.FullName, "obj"), recursive: true);
}
CopyFromTemplate(projectName, args, workingDirectory, templateDirectory);
@@ -120,7 +131,7 @@ internal void CreateDotnetToolProject(string solutionRoot, string projectName, s
DotnetToolReference
Exe
{targetFramework}
- {rid}
+ {rid}
{restorePackagesPath}
{restoreSolutionDirectory}
@@ -234,6 +245,48 @@ internal void BuildProject(string workingDirectory, string projectName, string a
Assert.True(result.Item3 == "", $"Build failed with following message in error stream :\n {result.AllOutput}");
}
+ internal TestDirectory CreateTestDirectory()
+ {
+ var testDirectory = TestDirectory.Create();
+
+ WriteGlobalJson(testDirectory);
+
+ return testDirectory;
+ }
+
+ internal SimpleTestPathContext CreateSimpleTestPathContext()
+ {
+ var simpleTestPathContext = new SimpleTestPathContext();
+
+ WriteGlobalJson(simpleTestPathContext.WorkingDirectory);
+
+ var addSourceArgs = new AddSourceArgs()
+ {
+ Configfile = simpleTestPathContext.NuGetConfig,
+ Name = "template",
+ Source = _templateDirectory.UserPackagesFolder
+ };
+ AddSourceRunner.Run(addSourceArgs, () => NullLogger.Instance);
+
+ return simpleTestPathContext;
+ }
+
+ internal TestDirectory Build(TestDirectoryBuilder testDirectoryBuilder)
+ {
+ var testDirectory = testDirectoryBuilder.Build();
+
+ WriteGlobalJson(testDirectory);
+
+ return testDirectory;
+ }
+
+ private void WriteGlobalJson(string path)
+ {
+ string globalJsonText = $"{{\"sdk\": {{\"version\": \"{SdkVersion}\"}}}}";
+ var globalJsonPath = Path.Combine(path, "global.json");
+ File.WriteAllText(globalJsonPath, globalJsonText);
+ }
+
private TestDirectory CopyLatestCliForPack()
{
var cliDirectory = TestDirectory.Create();
@@ -245,9 +298,28 @@ private TestDirectory CopyLatestCliForPack()
private void CopyLatestCliToTestDirectory(string destinationDir)
{
var cliDir = Path.GetDirectoryName(_dotnetCli);
+ var sdkDir = Path.Combine(cliDir, "sdk" + Path.DirectorySeparatorChar);
+
+ // Determine which SDK version to copy
+ SdkVersion = GetSdkToTest(sdkDir);
+
+ WriteGlobalJson(destinationDir);
- //Create sub-directory structure in destination
- foreach (var directory in Directory.GetDirectories(cliDir, "*", SearchOption.AllDirectories))
+ var sdkPath = Path.Combine(sdkDir, SdkVersion + Path.DirectorySeparatorChar);
+ var fallbackFolderPath = Path.Combine(sdkDir, "NuGetFallbackFolder");
+
+ Func predicate = path =>
+ {
+ if (!path.StartsWith(sdkDir))
+ {
+ return true;
+ }
+
+ return path.StartsWith(sdkPath) || path.StartsWith(fallbackFolderPath);
+ };
+
+ //Create sub-directory structure in destination, ignoring any SDK version not selected.
+ foreach (var directory in Directory.GetDirectories(cliDir, "*", SearchOption.AllDirectories).Where(predicate))
{
var destDir = destinationDir + directory.Substring(cliDir.Length);
if (!Directory.Exists(destDir))
@@ -258,8 +330,8 @@ private void CopyLatestCliToTestDirectory(string destinationDir)
var lastWriteTime = DateTime.Now.AddDays(-2);
- //Copy files recursively to destination directories
- foreach (var fileName in Directory.GetFiles(cliDir, "*", SearchOption.AllDirectories))
+ //Copy files recursively to destination directories, ignoring any SDK version not selected.
+ foreach (var fileName in Directory.GetFiles(cliDir, "*", SearchOption.AllDirectories).Where(predicate))
{
var destFileName = destinationDir + fileName.Substring(cliDir.Length);
File.Copy(fileName, destFileName);
@@ -267,6 +339,41 @@ private void CopyLatestCliToTestDirectory(string destinationDir)
}
}
+ private string GetSdkToTest(string sdkDir)
+ {
+ // The TFM we're testing
+ var testTfm = AssemblyReader.GetTargetFramework(typeof(MsbuildIntegrationTestFixture).Assembly.Location);
+
+ var selectedVersion =
+ Directory.GetDirectories(sdkDir) // get all directories in sdk folder
+ .Where(path =>
+ { // SDK is for TFM to test
+ if (string.Equals(Path.GetFileName(path), "NuGetFallbackFolder", StringComparison.OrdinalIgnoreCase))
+ {
+ return false;
+ }
+
+ var dotnetPath = Path.Combine(path, "dotnet.dll");
+ var sdkTfm = AssemblyReader.GetTargetFramework(dotnetPath);
+
+ return testTfm == sdkTfm;
+ })
+ .Select(Path.GetFileName) // just the folder name (version string)
+ .OrderByDescending(path => NuGetVersion.Parse(Path.GetFileName(path))) // in case there are multiple matching SDKs, selected the highest version
+ .FirstOrDefault();
+
+ if (selectedVersion == null)
+ {
+ var message = $@"Could not find suitable SDK to test in {sdkDir}
+TFM being tested: {testTfm.DotNetFrameworkName}
+SDKs found: {string.Join(", ", Directory.GetDirectories(sdkDir).Select(Path.GetFileName).Where(d => !string.Equals(d, "NuGetFallbackFolder", StringComparison.OrdinalIgnoreCase)))}";
+
+ throw new Exception(message);
+ }
+
+ return selectedVersion;
+ }
+
private void UpdateCliWithLatestNuGetAssemblies(string cliDirectory)
{
var artifactsDirectory = DotnetCliUtil.GetArtifactsDirectoryInRepo();
@@ -290,46 +397,69 @@ private void CopyRestoreArtifacts(string artifactsDirectory, string pathToSdkInC
const string restoreTargetsName = "NuGet.targets";
var sdkDependencies = new List { restoreProjectName, "NuGet.Versioning", "NuGet.Protocol", "NuGet.ProjectModel", "NuGet.Packaging", "NuGet.LibraryModel", "NuGet.Frameworks", "NuGet.DependencyResolver.Core", "NuGet.Configuration", "NuGet.Common", "NuGet.Commands", "NuGet.CommandLine.XPlat", "NuGet.Credentials" };
+ var sdkTfm = AssemblyReader.GetTargetFramework(Path.Combine(pathToSdkInCli, "dotnet.dll"));
+
// Copy rest of the NuGet assemblies.
foreach (var projectName in sdkDependencies)
{
- var projectArtifactsFolder = new DirectoryInfo(Path.Combine(artifactsDirectory, projectName, toolsetVersion, "bin", configuration));
-
- IEnumerable frameworkArtifactFolders = projectArtifactsFolder.EnumerateDirectories().Where(folder => folder.FullName.Contains("netcoreapp5.0"));
+ var projectArtifactsBinFolder = Path.Combine(artifactsDirectory, projectName, toolsetVersion, "bin", configuration);
- if (!frameworkArtifactFolders.Any())
- {
- frameworkArtifactFolders = projectArtifactsFolder.EnumerateDirectories().Where(folder => folder.FullName.Contains("netstandard2.0"));
- }
+ var tfmToCopy = GetTfmToCopy(sdkTfm, projectArtifactsBinFolder);
+ var frameworkArtifactsFolder = new DirectoryInfo(Path.Combine(projectArtifactsBinFolder, tfmToCopy));
- foreach (var frameworkArtifactsFolder in frameworkArtifactFolders)
+ var fileName = projectName + ".dll";
+ File.Copy(
+ sourceFileName: Path.Combine(frameworkArtifactsFolder.FullName, fileName),
+ destFileName: Path.Combine(pathToSdkInCli, fileName),
+ overwrite: true);
+ // Copy the restore targets.
+ if (projectName.Equals(restoreProjectName))
{
- var fileName = projectName + ".dll";
File.Copy(
- sourceFileName: Path.Combine(frameworkArtifactsFolder.FullName, fileName),
- destFileName: Path.Combine(pathToSdkInCli, fileName),
- overwrite: true);
- // Copy the restore targets.
- if (projectName.Equals(restoreProjectName))
- {
- File.Copy(
- sourceFileName: Path.Combine(frameworkArtifactsFolder.FullName, restoreTargetsName),
- destFileName: Path.Combine(pathToSdkInCli, restoreTargetsName),
- overwrite: true);
- }
+ sourceFileName: Path.Combine(frameworkArtifactsFolder.FullName, restoreTargetsName),
+ destFileName: Path.Combine(pathToSdkInCli, restoreTargetsName),
+ overwrite: true);
}
}
}
+ private string GetTfmToCopy(NuGetFramework sdkTfm, string projectArtifactsBinFolder)
+ {
+ var compiledTfms =
+ Directory.GetDirectories(projectArtifactsBinFolder) // get all directories in bin folder
+ .Select(Path.GetFileName) // just the folder name (tfm)
+ .ToDictionary(folder => NuGetFramework.Parse(folder));
+
+ var reducer = new FrameworkReducer();
+ var selectedTfm = reducer.GetNearest(sdkTfm, compiledTfms.Keys);
+
+ if (selectedTfm == null)
+ {
+ var message = $@"Could not find suitable assets to copy in {projectArtifactsBinFolder}
+TFM being tested: {sdkTfm}
+project TFMs found: {string.Join(", ", compiledTfms.Keys.Select(k => k.ToString()))}";
+
+ throw new Exception(message);
+ }
+
+ var selectedVersion = compiledTfms[selectedTfm];
+
+ return selectedVersion;
+ }
+
private void CopyPackSdkArtifacts(string artifactsDirectory, string pathToSdkInCli, string configuration, string toolsetVersion)
{
var pathToPackSdk = Path.Combine(pathToSdkInCli, "Sdks", "NuGet.Build.Tasks.Pack");
+ var sdkTfm = AssemblyReader.GetTargetFramework(Path.Combine(pathToSdkInCli, "dotnet.dll"));
const string packProjectName = "NuGet.Build.Tasks.Pack";
const string packTargetsName = "NuGet.Build.Tasks.Pack.targets";
// Copy the pack SDK.
- // Pick the netstandard2.0 NuGet.Build.Tasks.Pack dll
- var packProjectCoreArtifactsDirectory = new DirectoryInfo(Path.Combine(artifactsDirectory, packProjectName, toolsetVersion, "bin", configuration)).EnumerateDirectories("netstandard*").Single();
+
+ var packProjectBinDirectory = Path.Combine(artifactsDirectory, packProjectName, toolsetVersion, "bin", configuration);
+ var tfmToCopy = GetTfmToCopy(sdkTfm, packProjectBinDirectory);
+
+ var packProjectCoreArtifactsDirectory = new DirectoryInfo(Path.Combine(packProjectBinDirectory, tfmToCopy));
var packAssemblyDestinationDirectory = Path.Combine(pathToPackSdk, "CoreCLR");
// Be smart here so we don't have to call ILMerge in the VS build. It takes ~15s total.
// In VisualStudio, simply use the non il merged version.
@@ -405,7 +535,7 @@ private static void KillDotnetExe(string pathToDotnetExe)
}
///
- /// Depth-first recursive delete, with handling for descendant
+ /// Depth-first recursive delete, with handling for descendant
/// directories open in Windows Explorer or used by another process
///
private static void DeleteDirectory(string path)
@@ -453,16 +583,15 @@ private static void DeleteDirectory(string path)
/// Temporary patching process to bring in Cryptography DLLs for testing while SDK gets around to including them in 5.0.
/// See also: https://github.com/NuGet/Home/issues/8508
///
- private void PatchSDKWithCryptographyDlls(string dotnetMajorVersion, string[] sdkPaths)
+ private void PatchSDKWithCryptographyDlls(string sdkPath)
{
- string directoryToPatch = sdkPaths.Where(path => path.Split(Path.DirectorySeparatorChar).Last().StartsWith(dotnetMajorVersion)).First();
var assemblyNames = new string[1] { "System.Security.Cryptography.Pkcs.dll" };
- PatchDepsJsonFiles(assemblyNames, directoryToPatch);
+ PatchDepsJsonFiles(assemblyNames, sdkPath);
string userProfilePath = Environment.GetEnvironmentVariable(RuntimeEnvironmentHelper.IsWindows ? "USERPROFILE" : "HOME");
string globalPackagesPath = Path.Combine(userProfilePath, ".nuget", "packages");
- CopyNewlyAddedDlls(assemblyNames, Directory.GetCurrentDirectory(), directoryToPatch);
+ CopyNewlyAddedDlls(assemblyNames, Directory.GetCurrentDirectory(), sdkPath);
}
private void PatchDepsJsonFiles(string[] assemblyNames, string patchDir)
diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs
index 5bf196d9920..129f61f0d56 100644
--- a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs
+++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/PackCommandTests.cs
@@ -1,4 +1,3 @@
-
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
@@ -16,9 +15,6 @@
using NuGet.Test.Utility;
using NuGet.Versioning;
using Xunit;
-using NuGet.XPlat.FuncTest;
-
-
namespace Dotnet.Integration.Test
{
@@ -35,12 +31,12 @@ public PackCommandTests(MsbuildIntegrationTestFixture fixture)
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewDefaultProject_NupkgExists()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
msbuildFixture.RestoreProject(workingDirectory, projectName, string.Empty);
msbuildFixture.PackProject(workingDirectory, projectName, $"-o {workingDirectory}");
@@ -80,12 +76,12 @@ public void PackCommand_PackNewDefaultProject_NupkgExists()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewDefaultProject_IncludeSymbolsWithSnupkg()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
msbuildFixture.RestoreProject(workingDirectory, projectName, string.Empty);
msbuildFixture.PackProject(workingDirectory, projectName, $"--include-symbols /p:SymbolPackageFormat=snupkg -o {workingDirectory}");
@@ -119,12 +115,12 @@ public void PackCommand_PackNewDefaultProject_IncludeSymbolsWithSnupkg()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackProjectWithPackageType_SnupkgContainsOnlyOnePackageType()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj");
using (var stream = new FileStream(projectFile, FileMode.Open, FileAccess.ReadWrite))
@@ -171,7 +167,7 @@ public void PackCommand_PackProjectWithPackageType_SnupkgContainsOnlyOnePackageT
[InlineData(false)]
public void PackCommand_PackConsoleAppWithRID_NupkgValid(bool includeSymbols)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ConsoleApp1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -230,7 +226,7 @@ public void PackCommand_PackConsoleAppWithRID_NupkgValid(bool includeSymbols)
public void PackCommand_PackProject_PackageReferenceFloatingVersionRange()
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -295,7 +291,7 @@ public void PackCommand_PackProject_PackageReferenceFloatingVersionRange()
public async Task PackCommand_PackProject_PackageReferenceAllStableFloatingVersionRange_UsesRestoredVersionInNuspecAsync()
{
// Arrange
- using (var pathContext = new SimpleTestPathContext())
+ using (var pathContext = msbuildFixture.CreateSimpleTestPathContext())
{
var projectName = "ClassLibrary1";
var availableVersions = "1.0.0;2.0.0";
@@ -379,7 +375,7 @@ await SimpleTestPackageUtility.CreateFolderFeedV3Async(
public void PackCommand_PackProject_SupportMultipleFrameworks()
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -485,7 +481,7 @@ public void PackCommand_SupportsIncludeExcludePrivateAssets_OnPackages(
string expectedExclude)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -563,7 +559,7 @@ public void PackCommand_SupportsIncludeExcludePrivateAssets_OnPackages(
public void PackCommand_PackProject_AddsProjectRefsAsPackageRefs()
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var referencedProject = "ClassLibrary2";
@@ -571,8 +567,8 @@ public void PackCommand_PackProject_AddsProjectRefsAsPackageRefs()
var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj");
var framework = FrameworkConstants.CommonFrameworks.NetCoreApp31;
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName);
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, referencedProject, "classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, "console -f netcoreapp3.1");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, referencedProject, "classlib -f netstandard2.0");
using (var stream = new FileStream(projectFile, FileMode.Open, FileAccess.ReadWrite))
{
@@ -646,7 +642,7 @@ public void PackCommand_PackProject_AddsProjectRefsAsPackageRefs()
public void PackCommand_PackProject_ExactVersionOverrideProjectRefVersionInMsbuild(string tfmProperty, string tfmValue)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var referencedProject = "ClassLibrary2";
@@ -734,7 +730,7 @@ public void PackCommand_PackProject_ExactVersionOverrideProjectRefVersionInMsbui
public void PackCommand_PackProject_GetsProjectRefVersionFromMsbuild(string tfmProperty, string tfmValue)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var referencedProject = "ClassLibrary2";
@@ -809,7 +805,7 @@ public void PackCommand_PackProject_GetsProjectRefVersionFromMsbuild(string tfmP
public void PackCommand_PackProject_GetPackageVersionDependsOnWorks(string tfmProperty, string tfmValue)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var referencedProject = "ClassLibrary2";
@@ -902,7 +898,7 @@ public void PackCommand_PackProject_PacksFromNuspec()
";
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -941,7 +937,7 @@ public void PackCommand_PackProject_PacksFromNuspec()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackProject_EmptyNuspecFilePropertyWithNuspecProperties()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -987,7 +983,7 @@ public void PackCommand_PackProject_PackNuspecWithoutBuild()
";
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1034,12 +1030,12 @@ public void PackCommand_PackProject_PackNuspecWithoutBuild()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewDefaultProject_InstallPackageToOutputPath()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
msbuildFixture.RestoreProject(workingDirectory, projectName, string.Empty);
msbuildFixture.PackProject(workingDirectory, projectName, $"-o {workingDirectory} /p:OutputFileNamesWithoutVersion=true /p:InstallPackageToOutputPath=true");
@@ -1091,7 +1087,7 @@ public void PackCommand_PackProject_PacksFromNuspec_InstallPackageToOutputPath()
This was packed from nuspec
";
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1162,7 +1158,7 @@ string expectedTags
";
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1215,8 +1211,8 @@ public void PackCommand_PackProject_PacksFromNuspecWithBasePath()
";
- using (var basePathDirectory = TestDirectory.Create())
- using (var testDirectory = TestDirectory.Create())
+ using (var basePathDirectory = msbuildFixture.CreateTestDirectory())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1299,7 +1295,7 @@ public void PackCommand_PackProject_PackagePathPacksContentCorrectly(string sour
string expectedTargetPaths)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
@@ -1392,7 +1388,7 @@ public void PackCommand_PackProject_OutputsCorrectVersion(string versionPrefix,
string packageVersion, string expectedVersion)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1485,7 +1481,7 @@ public void PackCommand_PackProject_OutputsContentFilesInNuspecForSingleFramewor
string packagePath, string expectedIncludeString)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
@@ -1581,7 +1577,7 @@ public void PackCommand_PackProject_OutputsContentFilesInNuspecForMultipleFramew
string expectedIncludeString)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
@@ -1665,7 +1661,7 @@ public void PackCommand_PackProject_OutputsContentFilesInNuspecForMultipleFramew
[PlatformFact(Platform.Windows)]
public void PackCommand_SingleFramework_GeneratesPackageOnBuild()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1730,7 +1726,7 @@ public void PackCommand_SingleFramework_GeneratesPackageOnBuild()
[InlineData("netstandard1.4;net451;netcoreapp1.0")]
public void PackCommand_MultipleFrameworks_GeneratesPackageOnBuild(string frameworks)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1791,12 +1787,12 @@ public void PackCommand_MultipleFrameworks_GeneratesPackageOnBuild(string framew
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewDefaultProject_IncludeBuildOutputDoesNotCreateLibFolder()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
msbuildFixture.RestoreProject(workingDirectory, projectName, string.Empty);
using (var stream = new FileStream(Path.Combine(workingDirectory, $"{projectName}.csproj"), FileMode.Open, FileAccess.ReadWrite))
@@ -1856,13 +1852,13 @@ public void PackCommand_PackNewDefaultProject_IncludeBuildOutputDoesNotCreateLib
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewDefaultProject_BuildOutputTargetFolderOutputsLibsToRightFolder()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var buildOutputTargetFolder = "build";
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
msbuildFixture.RestoreProject(workingDirectory, projectName, string.Empty);
msbuildFixture.PackProject(workingDirectory, projectName,
$"-o {workingDirectory} /p:BuildOutputTargetFolder={buildOutputTargetFolder}");
@@ -1891,7 +1887,7 @@ public void PackCommand_PackNewDefaultProject_BuildOutputTargetFolderOutputsLibs
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewProject_CleanDeletesNupkgAndNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -1930,7 +1926,7 @@ public void PackCommand_PackNewProject_CleanDeletesNupkgAndNuspec()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackNewProject_CleanDeletesOnlyGeneratedNupkgAndNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2016,7 +2012,7 @@ public void PackCommand_PackProject_ContentTargetFoldersPacksContentCorrectly(st
string contentTargetFolders, string expectedTargetPaths)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
@@ -2095,7 +2091,7 @@ public void PackCommand_PackProject_ContentTargetFoldersPacksContentCorrectly(st
[PlatformFact(Platform.Windows)]
public void PackCommand_NewProject_AddsTitleToNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2157,7 +2153,7 @@ public void PackCommand_NewProject_AddsTitleToNuspec()
[InlineData("TargetFrameworks", "netstandard1.4;net46")]
public void PackCommand_IncludeSource_AddsSourceFiles(string tfmProperty, string tfmValue)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var utilitySrcFileContent = @"using System;
namespace ClassLibrary
@@ -2224,7 +2220,7 @@ public class ExtensionMethods
[InlineData("TargetFrameworks", "netstandard1.4;net46")]
public void PackCommand_ContentInnerTargetExtension_AddsTfmSpecificContent(string tfmProperty, string tfmValue)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2298,7 +2294,7 @@ public void PackCommand_ContentInnerTargetExtension_AddsTfmSpecificContent(strin
public void PackCommand_BuildOutputInnerTargetExtension_AddsTfmSpecificBuildOuput(string tfmProperty,
string tfmValue)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2389,7 +2385,7 @@ public void PackCommand_PackProject_GlobbingPathsPacksContentCorrectly(string so
string expectedTargetPaths)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2460,7 +2456,7 @@ public void PackCommand_PackProject_AddsReferenceAsFrameworkAssemblyReference(st
string targetFrameworks, string conditionalFramework, string expectedTargetFramework)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2540,7 +2536,7 @@ public void PackCommand_PackProject_AddsReferenceAsFrameworkAssemblyReference(st
public void PackCommand_PackProject_OutputsBuildActionForContentFiles(string itemType, string buildAction, string expectedBuildAction )
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2598,7 +2594,7 @@ public void PackCommand_PackProject_OutputsBuildActionForContentFiles(string ite
public void PackCommand_PackSolution_AddsProjectRefsAsPackageRefs()
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var solutionName = "Solution1";
var projectName = "ClassLibrary1";
@@ -2614,9 +2610,9 @@ public void PackCommand_PackSolution_AddsProjectRefsAsPackageRefs()
var referencedProject1RelativDir = Path.Combine(projectAndReference1Folder, referencedProject1, $"{referencedProject1}.csproj");
var referencedProject2RelativDir = Path.Combine(rederence2Folder, referencedProject2, $"{referencedProject2}.csproj");
- msbuildFixture.CreateDotnetNewProject(Path.Combine(testDirectory.Path, projectAndReference1Folder), projectName, "classlib");
- msbuildFixture.CreateDotnetNewProject(Path.Combine(testDirectory.Path, projectAndReference1Folder), referencedProject1, "classlib");
- msbuildFixture.CreateDotnetNewProject(Path.Combine(testDirectory.Path, rederence2Folder), referencedProject2, "classlib");
+ msbuildFixture.CreateDotnetNewProject(Path.Combine(testDirectory.Path, projectAndReference1Folder), projectName, "classlib -f netstandard2.0");
+ msbuildFixture.CreateDotnetNewProject(Path.Combine(testDirectory.Path, projectAndReference1Folder), referencedProject1, "classlib -f netstandard2.0");
+ msbuildFixture.CreateDotnetNewProject(Path.Combine(testDirectory.Path, rederence2Folder), referencedProject2, "classlib -f netstandard2.0");
msbuildFixture.RunDotnet(testDirectory.Path, $"new solution -n {solutionName}");
msbuildFixture.RunDotnet(testDirectory.Path, $"sln {solutionName}.sln add {projectFileRelativ}");
@@ -2708,7 +2704,7 @@ public void PackCommand_PackSolution_AddsProjectRefsAsPackageRefs()
public void PackCommand_PackTargetHook_ExecutesBeforePack(string tfmProperty,
string tfmValue)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2748,7 +2744,7 @@ public void PackCommand_PackTargetHook_ExecutesBeforePack(string tfmProperty,
[InlineData("TargetFrameworks", "netstandard1.4;net46")]
public void PackCommand_PackTarget_IsIncremental(string tfmProperty, string tfmValue)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2792,7 +2788,7 @@ public void PackCommand_PackTarget_IsIncremental(string tfmProperty, string tfmV
[InlineData("NoWarn", "NU5106", true)]
public void PackCommand_NoWarn_SuppressesWarnings(string property, string value, bool expectToWarn)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2837,7 +2833,7 @@ public void PackCommand_NoWarn_SuppressesWarnings(string property, string value,
[InlineData("TreatWarningsAsErrors", "true", true)]
public void PackCommand_WarnAsError_PrintsWarningsAsErrors(string property, string value, bool expectToError)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var semver2Version = "1.0.0-rtm+asdassd";
var projectName = "ClassLibrary1";
@@ -2880,7 +2876,7 @@ public void PackCommand_WarnAsError_PrintsWarningsAsErrors(string property, stri
[PlatformFact(Platform.Windows)]
public void PackCommand_IncrementalPack_FailsWhenInvokedTwiceInARow()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var semver2Version = "1.0.0-rtm+asdassd";
var projectName = "ClassLibrary1";
@@ -2924,7 +2920,7 @@ public void PackCommand_IncrementalPack_FailsWhenInvokedTwiceInARow()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackWithRepositoryVerifyNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -2967,7 +2963,7 @@ public void PackCommand_PackWithRepositoryVerifyNuspec()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackWithSourceControlInformation_Unsupported_VerifyNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -3023,7 +3019,7 @@ public void PackCommand_PackWithSourceControlInformation_Unsupported_VerifyNuspe
[PlatformFact(Platform.Windows)]
public void PackCommand_PackWithSourceControlInformation_PrivateUrl_VerifyNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -3084,7 +3080,7 @@ public void PackCommand_PackWithSourceControlInformation_PrivateUrl_VerifyNuspec
[PlatformFact(Platform.Windows)]
public void PackCommand_PackWithSourceControlInformation_PublishedUrl_VerifyNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -3145,7 +3141,7 @@ public void PackCommand_PackWithSourceControlInformation_PublishedUrl_VerifyNusp
[PlatformFact(Platform.Windows)]
public void PackCommand_PackWithSourceControlInformation_ProjectOverride_VerifyNuspec()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -3205,7 +3201,7 @@ public void PackCommand_PackWithSourceControlInformation_ProjectOverride_VerifyN
public void PackCommand_ManualAddPackage_DevelopmentDependency()
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -3268,7 +3264,7 @@ public void PackCommand_ManualAddPackage_DevelopmentDependency()
public void PackCommand_SuppressDependencies_DoesNotContainAnyDependency(string frameworkToSuppress, string expectedInFramework)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -3339,7 +3335,7 @@ public void PackCommand_SuppressDependencies_DoesNotContainAnyDependency(string
[InlineData("MIT OR Apache-2.0 WITH 389-exception")]
public void PackCommand_PackLicense_SimpleExpression_StandardLicense(string licenseExpr)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
@@ -3388,7 +3384,7 @@ public void PackCommand_PackLicense_SimpleExpression_StandardLicense(string lice
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_ComplexExpression_WithNonStandardLicense()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var customLicense = "LicenseRef-Nikolche";
var licenseExpr = $"MIT OR {customLicense} WITH 389-exception";
@@ -3444,7 +3440,7 @@ public void PackCommand_PackLicense_ComplexExpression_WithNonStandardLicense()
[InlineData("Tanana AND nana nana")]
public void PackCommand_PackLicense_NonParsableExpressionFailsErrorWithCode(string licenseExpr)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
@@ -3476,7 +3472,7 @@ public void PackCommand_PackLicense_NonParsableExpressionFailsErrorWithCode(stri
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_NonParsableVersionFailsErrorWithCode()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var licenseExpr = "MIT OR Apache-2.0";
var version = "1.0.0-babanana";
@@ -3511,7 +3507,7 @@ public void PackCommand_PackLicense_NonParsableVersionFailsErrorWithCode()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_ExpressionVersionHigherFailsWithErrorCode()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var licenseExpr = "MIT OR Apache-2.0";
var version = "2.0.0";
@@ -3550,7 +3546,7 @@ public void PackCommand_PackLicense_ExpressionVersionHigherFailsWithErrorCode()
[InlineData("LICENSE.txt", "LICENSE.txt")]
public void PackCommand_PackLicense_PackBasicLicenseFile(string licenseFileName, string packagesPath)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
@@ -3618,7 +3614,7 @@ public void PackCommand_PackLicense_PackBasicLicenseFile(string licenseFileName,
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_PackBasicLicenseFile_FileNotInPackage()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var licenseFileName = "LICENSE.txt";
@@ -3655,7 +3651,7 @@ public void PackCommand_PackLicense_PackBasicLicenseFile_FileNotInPackage()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_PackBasicLicenseFile_FileExtensionNotValid()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var licenseFileName = "LICENSE.badextension";
// Set up
@@ -3692,7 +3688,7 @@ public void PackCommand_PackLicense_PackBasicLicenseFile_FileExtensionNotValid()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_BothLicenseExpressionAndFile_FailsWithErrorCode()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
@@ -3727,7 +3723,7 @@ public void PackCommand_PackLicense_BothLicenseExpressionAndFile_FailsWithErrorC
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_LicenseUrlIsBeingDeprecated()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
@@ -3772,13 +3768,13 @@ public void PackCommand_PackLicense_LicenseUrlIsBeingDeprecated()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_IncludeLicenseFileWithSnupkg()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
var licenseFileName = "LICENSE.txt";
var workingDirectory = Path.Combine(testDirectory, projectName);
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj");
var licenseFile = Path.Combine(workingDirectory, licenseFileName);
File.WriteAllText(licenseFile, "Random licenseFile");
@@ -3858,13 +3854,13 @@ public void PackCommand_PackLicense_IncludeLicenseFileWithSnupkg()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackLicense_IncludeLicenseFileWithSymbolsNupkg()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
var licenseFileName = "LICENSE.txt";
var workingDirectory = Path.Combine(testDirectory, projectName);
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj");
var licenseFile = Path.Combine(workingDirectory, licenseFileName);
File.WriteAllText(licenseFile, "Random licenseFile");
@@ -3943,7 +3939,7 @@ public void PackCommand_PackLicense_IncludeLicenseFileWithSymbolsNupkg()
[InlineData("PackageLicenseFile")]
public void PackCommand_PackLicense_LicenseExpressionAndLicenseUrlInConjunction(string licenseType)
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
// Set up
var projectName = "ClassLibrary1";
@@ -3977,11 +3973,11 @@ public void PackCommand_PackLicense_LicenseExpressionAndLicenseUrlInConjunction(
[PlatformFact(Platform.Windows)]
public void PackCommand_PackEmbedInteropPackage()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib");
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0");
var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj");
// Setup BuildOutputTargetFolder
@@ -4022,7 +4018,7 @@ public void PackCommand_PackEmbedInteropPackage()
public void PackCommand_PackProject_PacksFrameworkReferences(string frameworkReferences, string packForFrameworkRefs, string targetFrameworks, string conditionalFramework, string expectedTargetFramework)
{
// Arrange
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -4111,7 +4107,7 @@ public void PackCommand_PackProject_PacksFrameworkReferences(string frameworkRef
[PlatformFact(Platform.Windows)]
public void PackCommand_WithGeneratePackageOnBuildSet_CanPublish()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -4136,7 +4132,7 @@ public void PackCommand_WithGeneratePackageOnBuildSet_CanPublish()
[PlatformFact(Platform.Windows, Skip = "https://github.com/NuGet/Home/issues/8601")]
public void PackCommand_Deterministic_MultiplePackInvocations_CreateIdenticalPackages()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -4211,7 +4207,7 @@ public void PackCommand_PackageIcon_HappyPath_Warns_Succeeds()
.WithItem("None", "folder\\**", "media")
.WithItem("None", "utils\\*", "utils");
- using (var srcDir = testDirBuilder.Build())
+ using (var srcDir = msbuildFixture.Build(testDirBuilder))
{
projectBuilder.Build(msbuildFixture, srcDir.Path);
var result = msbuildFixture.PackProject(projectBuilder.ProjectFolder, projectBuilder.ProjectName, string.Empty);
@@ -4240,7 +4236,7 @@ public void PackCommand_PackageIcon_MissingFile_Fails()
.WithProjectName("test")
.WithPackageIcon("icon.jpg");
- using (var srcDir = testDirBuilder.Build())
+ using (var srcDir = msbuildFixture.Build(testDirBuilder))
{
projectBuilder.Build(msbuildFixture, srcDir.Path);
var result = msbuildFixture.PackProject(projectBuilder.ProjectFolder, projectBuilder.ProjectName, string.Empty, validateSuccess: false);
@@ -4266,7 +4262,7 @@ public void PackCommand_PackageIcon_PackWithSymbols_Succeeds(string symbolPackag
.WithPackageIcon("icon.jpg")
.WithItem("None", "icon.jpg", "icon.jpg");
- using (var srcDir = testDirBuilder.Build())
+ using (var srcDir = msbuildFixture.Build(testDirBuilder))
{
projectBuilder.Build(msbuildFixture, srcDir.Path);
var result = msbuildFixture.PackProject(
@@ -4298,7 +4294,7 @@ public void PackCommand_PackIcon_WithNuspec_IconUrl_Warns_Succeeds()
.WithNuspec(nuspecBuilder, "test\\test.nuspec")
.WithFile("test\\dummy.txt", 10);
- using (var srcDir = testDirBuilder.Build())
+ using (var srcDir = msbuildFixture.Build(testDirBuilder))
{
projectBuilder.Build(msbuildFixture, srcDir.Path);
var result = msbuildFixture.PackProject(projectBuilder.ProjectFolder, projectBuilder.ProjectName, string.Empty);
@@ -4312,7 +4308,7 @@ public void PackCommand_PackIcon_WithNuspec_IconUrl_Warns_Succeeds()
[PlatformFact(Platform.Windows)]
public void PackCommand_WhenUsingSemver2Version_NU5105_IsNotRaised()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
@@ -4344,14 +4340,14 @@ public void PackCommand_WhenUsingSemver2Version_NU5105_IsNotRaised()
[PlatformFact(Platform.Windows)]
public void PackCommand_PackProjectWithCentralTransitiveDependencies()
{
- using (var testDirectory = TestDirectory.Create())
+ using (var testDirectory = msbuildFixture.CreateTestDirectory())
{
var projectName = "ClassLibrary1";
var workingDirectory = Path.Combine(testDirectory, projectName);
var projectFile = Path.Combine(workingDirectory, $"{projectName}.csproj");
// Act
- msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib", 60000);
+ msbuildFixture.CreateDotnetNewProject(testDirectory.Path, projectName, " classlib -f netstandard2.0", 60000);
using (var stream = new FileStream(projectFile, FileMode.Open, FileAccess.ReadWrite))
{
diff --git a/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Utils/AssemblyReader.cs b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Utils/AssemblyReader.cs
new file mode 100644
index 00000000000..7ddedc6a409
--- /dev/null
+++ b/test/NuGet.Core.FuncTests/Dotnet.Integration.Test/Utils/AssemblyReader.cs
@@ -0,0 +1,81 @@
+// Copyright (c) .NET Foundation. All rights reserved.
+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
+
+using System;
+using System.IO;
+using System.Reflection.Metadata;
+using System.Reflection.PortableExecutable;
+using NuGet.Frameworks;
+
+namespace Dotnet.Integration.Test.Utils
+{
+ internal static class AssemblyReader
+ {
+ internal static NuGetFramework GetTargetFramework(string assemblyPath)
+ {
+ using (var fileStream = File.OpenRead(assemblyPath))
+ using (var peReader = new PEReader(fileStream))
+ {
+ var metadataReader = peReader.GetMetadataReader();
+ var targetFrameworkAttribute = GetTargetFrameworkAttribute(metadataReader);
+ var targetFrameworkString = GetTargetFrameworkString(targetFrameworkAttribute, metadataReader);
+ var targetFramework = NuGetFramework.Parse(targetFrameworkString);
+ return targetFramework;
+ }
+ }
+
+ private static CustomAttribute GetTargetFrameworkAttribute(MetadataReader metadataReader)
+ {
+ foreach (var customAttributeHandle in metadataReader.CustomAttributes)
+ {
+ var customAttribute = metadataReader.GetCustomAttribute(customAttributeHandle);
+ switch (customAttribute.Constructor.Kind)
+ {
+ case HandleKind.MemberReference:
+ {
+ var memberReference = metadataReader.GetMemberReference((MemberReferenceHandle)customAttribute.Constructor);
+ var name = GetMemberName(memberReference, metadataReader);
+
+ if (name == "System.Runtime.Versioning.TargetFrameworkAttribute..ctor")
+ {
+ return customAttribute;
+ }
+ }
+ break;
+
+ default:
+ throw new NotSupportedException(customAttribute.Constructor.Kind.ToString());
+ }
+ }
+
+ throw new Exception("Assembly doesn't have a TargetFrameworkAttribute");
+ }
+
+ private static string GetMemberName(MemberReference memberReference, MetadataReader metadataReader)
+ {
+ if (memberReference.Parent.Kind != HandleKind.TypeReference)
+ {
+ throw new NotSupportedException("Didn't expect member reference parent to be of kind " + memberReference.Parent.Kind);
+ }
+
+ var typeReference = metadataReader.GetTypeReference((TypeReferenceHandle)memberReference.Parent);
+
+ var memberName = metadataReader.GetString(memberReference.Name);
+ var typeName = metadataReader.GetString(typeReference.Name);
+ var namespaceName = metadataReader.GetString(typeReference.Namespace);
+
+ return namespaceName + "." + typeName + "." + memberName;
+ }
+
+ private static string GetTargetFrameworkString(CustomAttribute targetFrameworkAttribute, MetadataReader metadataReader)
+ {
+ var blobReader = metadataReader.GetBlobReader(targetFrameworkAttribute.Value);
+
+ // I'm not sure if this is IL, or just a list of arguments, but the first value is a 16-bit number with the value 1
+ blobReader.ReadInt16();
+
+ // Next is the string passed to the TargetFrameworkAttribute constructor
+ return blobReader.ReadSerializedString();
+ }
+ }
+}
diff --git a/test/NuGet.Core.FuncTests/NuGet.XPlat.FuncTest/NuGet.XPlat.FuncTest.csproj b/test/NuGet.Core.FuncTests/NuGet.XPlat.FuncTest/NuGet.XPlat.FuncTest.csproj
index 0cf5717cff1..64fae6cc25d 100644
--- a/test/NuGet.Core.FuncTests/NuGet.XPlat.FuncTest/NuGet.XPlat.FuncTest.csproj
+++ b/test/NuGet.Core.FuncTests/NuGet.XPlat.FuncTest/NuGet.XPlat.FuncTest.csproj
@@ -1,7 +1,6 @@
true
- true