Skip to content

Commit

Permalink
Run dotnet nuget tests on multiple TFMs
Browse files Browse the repository at this point in the history
  • Loading branch information
zivkan committed May 26, 2020
1 parent ed29dd8 commit 7d3c4f5
Show file tree
Hide file tree
Showing 11 changed files with 430 additions and 227 deletions.
4 changes: 2 additions & 2 deletions build/common.project.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<NETFXTargetFramework>net472</NETFXTargetFramework>
<NETCoreTargetFramework>netcoreapp2.1</NETCoreTargetFramework>
<NETCoreTargetFrameworks Condition=" '$(RequiresSigningXplatAPIs)' != 'true' ">netcoreapp2.1</NETCoreTargetFrameworks>
<NETCoreTargetFrameworks Condition=" '$(RequiresSigningXplatAPIs)' == 'true' and '$(TestForLatestNetCoreOnly)' != 'true' ">netcoreapp2.1;netcoreapp5.0</NETCoreTargetFrameworks>
<NETCoreTargetFrameworks Condition=" '$(RequiresSigningXplatAPIs)' == 'true' and '$(TestForLatestNetCoreOnly)' == 'true' ">netcoreapp5.0</NETCoreTargetFrameworks>
<NETCoreTargetFrameworks Condition=" '$(RequiresSigningXplatAPIs)' == 'true' ">netcoreapp2.1;netcoreapp5.0</NETCoreTargetFrameworks>
<NETCoreTestTargetFrameworks>netcoreapp3.1;netcoreapp5.0</NETCoreTestTargetFrameworks>
<NetStandardVersion>netstandard2.0</NetStandardVersion>
<TargetFrameworksExe>$(NETFXTargetFramework);$(NETCoreTargetFrameworks)</TargetFrameworksExe>
<TargetFrameworksLibrary Condition=" '$(RequiresSigningXplatAPIs)' != 'true' ">$(NETFXTargetFramework);$(NetStandardVersion)</TargetFrameworksLibrary>
Expand Down
14 changes: 7 additions & 7 deletions build/config.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,35 @@
<MinorNuGetVersion Condition="'$(MinorNuGetVersion)' == ''">7</MinorNuGetVersion>
<PatchNuGetVersion Condition="'$(PatchNuGetVersion)' == ''">0</PatchNuGetVersion>
<SemanticVersion Condition=" '$(SemanticVersion)' == '' ">$(MajorNuGetVersion).$(MinorNuGetVersion).$(PatchNuGetVersion)</SemanticVersion>

<!-- ** Change for each new preview/rtm -->
<!-- Check the VS schedule and manually enter a preview number here that makes sense. -->
<ReleaseLabel Condition=" '$(ReleaseLabel)' == '' ">preview.2</ReleaseLabel>

<!-- ** Increment each insertion, set to zero after incrementing Major/Minor or Patch version -->
<!-- We need to update this netcoreassembly build number with EVERY insertion into VS to workaround any breaking api
changes we might have made. -->
<NetCoreAssemblyBuildNumber Condition=" '$(NetCoreAssemblyBuildNumber)' == '' ">2</NetCoreAssemblyBuildNumber>

<IsEscrowMode>false</IsEscrowMode>

<!-- Visual Studio Insertion Logic -->
<!-- Visual Studio Insertion Logic -->
<VsTargetMajorVersion>$([MSBuild]::Add(11, $(MajorNuGetVersion)))</VsTargetMajorVersion>
<VsTargetBranch>master</VsTargetBranch>
<VsTargetChannel>int.$(VsTargetBranch)</VsTargetChannel>

<!-- This branches are used for creating insertion PRs -->
<VsTargetBranch Condition="'$(IsEscrowMode)' == 'true'">rel/d$(VsTargetMajorVersion).$(MinorNuGetVersion)</VsTargetBranch>
<VsTargetChannel Condition="'$(IsEscrowMode)' == 'true'">int.d$(VsTargetMajorVersion).$(MinorNuGetVersion)</VsTargetChannel>

<!-- .NET Core SDK Insertion Logic -->
<!-- .NET Core SDK Insertion Logic -->
<!-- when LockSDKVersion is true, it will use the specific version in CliVersionForBuilding for building, and specific version in OverrideCliBranchForTesting for testing, -->
<!-- when LockSDKVersion is false, it will ignore the properties and just use the latest version for the channel specified in CliVersionForBuilding for building, CliBranchForTesting for testing -->
<LockSDKVersion>true</LockSDKVersion>
<OverrideCliBranchForTesting Condition="'$(LockSDKVersion)' == 'false'"></OverrideCliBranchForTesting>
<OverrideCliBranchForTesting Condition="'$(LockSDKVersion)' == 'true'">master</OverrideCliBranchForTesting>
<OverrideCliBranchForTesting Condition="'$(LockSDKVersion)' == 'true'">master;3.1</OverrideCliBranchForTesting>
<CliVersionForBuilding Condition="'$(LockSDKVersion)' == 'false'">master</CliVersionForBuilding>
<CliVersionForBuilding Condition="'$(LockSDKVersion)' == 'true'">"master 5.0.100-preview.3.20216.6"</CliVersionForBuilding>
<CliVersionForBuilding Condition="'$(LockSDKVersion)' == 'true'">"master 5.0.100-preview.3.20216.6"</CliVersionForBuilding>
<CliBranchForTesting Condition="'$(OverrideCliBranchForTesting)' != ''">$(OverrideCliBranchForTesting)</CliBranchForTesting>
<CliBranchForTesting Condition="'$(OverrideCliBranchForTesting)' == ''">master</CliBranchForTesting>
<CliTargetBranches Condition="'$(OverrideCliTargetBranches)' != ''">$(OverrideCliTargetBranches)</CliTargetBranches>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<Project>
<Project>
<PropertyGroup>
<RequiresSigningXplatAPIs>true</RequiresSigningXplatAPIs>
<TestForLatestNetCoreOnly>true</TestForLatestNetCoreOnly>
</PropertyGroup>

<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'README.md'))\build\common.test.props" />
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<PropertyGroup>
<TargetFrameworks>$(NETCoreTargetFrameworks)</TargetFrameworks>
<TargetFrameworks>$(NETCoreTestTargetFrameworks)</TargetFrameworks>
<TestProject>true</TestProject>
<Description>Integration tests for NuGet-powered dotnet CLI commands such as pack/restore/list package and dotnet nuget.</Description>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand All @@ -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");

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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");

Expand All @@ -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");
Expand Down Expand Up @@ -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<string> { "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" };
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down Expand Up @@ -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))
{
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");

Expand All @@ -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
Expand Down Expand Up @@ -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<string, SimpleTestProjectContext>();
Expand Down Expand Up @@ -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<string, SimpleTestProjectContext>();
var sources = new List<string>();
Expand Down Expand Up @@ -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);
Expand Down
Loading

0 comments on commit 7d3c4f5

Please sign in to comment.