Merge branch 'release/5.0.1xx-preview1' into merge/release/3.1.2xx-to-master

This commit is contained in:
Nick Guerrera 2020-02-19 13:50:39 -08:00
commit 03963a5788
97 changed files with 2409 additions and 1864 deletions

View file

@ -7,11 +7,6 @@
<!-- Copy empty Directory.Build files to stop tests from getting repo build logic -->
<Content Include="$(RepoRoot)TestAssets\Directory.Build.props" LinkBase="Tests" CopyToOutputDirectory="PreserveNewest" />
<Content Include="$(RepoRoot)TestAssets\Directory.Build.targets" LinkBase="Tests" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(MicrosoftDotNetPlatformAbstractionsPackageVersion)" />
</ItemGroup>
<ItemGroup>

View file

@ -19,7 +19,7 @@ namespace EndToEnd
[ClassData(typeof(SupportedNetCoreAppVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfNetCore(string minorVersion)
{
if (minorVersion == "3.0" || minorVersion == "3.1")
if (minorVersion == "3.0" || minorVersion == "3.1" || minorVersion == "5.0")
{
// https://github.com/dotnet/core-sdk/issues/621
return;
@ -31,7 +31,7 @@ namespace EndToEnd
[ClassData(typeof(SupportedAspNetCoreVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreApp(string minorVersion)
{
if (minorVersion == "3.0" || minorVersion == "3.1")
if (minorVersion == "3.0" || minorVersion == "3.1" || minorVersion == "5.0")
{
// https://github.com/dotnet/core-sdk/issues/621
return;

View file

@ -0,0 +1,195 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Xml.Linq;
using FluentAssertions;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.ProjectModel;
using NuGet.Versioning;
using Xunit;
namespace EndToEnd
{
public partial class GivenSelfContainedAppsRollForward : TestBase
{
[Theory]
// MemberData is used instead of InlineData here so we can access it in another test to
// verify that we are covering the latest release of .NET Core
[ClassData(typeof(SupportedNetCoreAppVersions))]
public void ItRollsForwardToTheLatestNetCoreVersion(string minorVersion)
{
if (minorVersion == "3.0" || minorVersion == "3.1" || minorVersion == "5.0")
{
// https://github.com/dotnet/core-sdk/issues/621
return;
}
ItRollsForwardToTheLatestVersion(TestProjectCreator.NETCorePackageName, minorVersion);
}
[Theory]
[ClassData(typeof(SupportedAspNetCoreVersions))]
public void ItRollsForwardToTheLatestAspNetCoreAppVersion(string minorVersion)
{
if (minorVersion == "3.0" || minorVersion == "3.1" || minorVersion == "5.0")
{
// https://github.com/dotnet/core-sdk/issues/621
return;
}
ItRollsForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAppPackageName, minorVersion);
}
[Theory]
[ClassData(typeof(SupportedAspNetCoreAllVersions))]
public void ItRollsForwardToTheLatestAspNetCoreAllVersion(string minorVersion)
{
ItRollsForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion);
}
internal void ItRollsForwardToTheLatestVersion(string packageName, string minorVersion)
{
var testProjectCreator = new TestProjectCreator()
{
PackageName = packageName,
MinorVersion = minorVersion,
// Set RuntimeIdentifier to opt in to roll-forward behavior
RuntimeIdentifier = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
};
var testInstance = testProjectCreator.Create();
string projectDirectory = testInstance.Root.FullName;
// Get the version rolled forward to
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
var assetsFile = new LockFileFormat().Read(assetsFilePath);
var rolledForwardVersion = GetPackageVersion(assetsFile, packageName);
rolledForwardVersion.Should().NotBeNull();
if (rolledForwardVersion.IsPrerelease)
{
// If this version of .NET Core is still prerelease, then:
// - Floating the patch by adding ".*" to the major.minor version won't work, but
// - There aren't any patches to roll-forward to, so we skip testing this until the version
// leaves prerelease.
return;
}
testProjectCreator.Identifier = "floating";
var floatingProjectInstance = testProjectCreator.Create();
var floatingProjectPath = Path.Combine(floatingProjectInstance.Root.FullName, "TestAppSimple.csproj");
var floatingProject = XDocument.Load(floatingProjectPath);
var ns = floatingProject.Root.Name.Namespace;
if (packageName == TestProjectCreator.NETCorePackageName)
{
// Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
floatingProject.Root.Element(ns + "PropertyGroup")
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
}
else
{
floatingProject.Root.Element(ns + "ItemGroup")
.Element(ns + "PackageReference")
.Add(new XAttribute("Version", $"{minorVersion}.*"),
new XAttribute("AllowExplicitVersion", "true"));
}
floatingProject.Save(floatingProjectPath);
new RestoreCommand()
.WithWorkingDirectory(floatingProjectInstance.Root.FullName)
.Execute()
.Should().Pass();
string floatingAssetsFilePath = Path.Combine(floatingProjectInstance.Root.FullName, "obj", "project.assets.json");
var floatedAssetsFile = new LockFileFormat().Read(floatingAssetsFilePath);
var floatedVersion = GetPackageVersion(floatedAssetsFile, packageName);
floatedVersion.Should().NotBeNull();
rolledForwardVersion.ToNormalizedString().Should().BeEquivalentTo(floatedVersion.ToNormalizedString(),
$"the latest patch version for {packageName} {minorVersion} in Microsoft.NETCoreSdk.BundledVersions.props " +
"needs to be updated (see the ImplicitPackageVariable items in MSBuildExtensions.targets in this repo)");
}
private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName)
{
return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null)
?.Libraries?.SingleOrDefault(l =>
string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0)
?.Version;
}
[Fact]
public void WeCoverLatestNetCoreAppRollForward()
{
// Run "dotnet new console", get TargetFramework property, and make sure it's covered in SupportedNetCoreAppVersions
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute("console --no-restore")
.Should().Pass();
string projectPath = Path.Combine(projectDirectory, Path.GetFileName(projectDirectory) + ".csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
string targetFramework = project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework")
.Value;
SupportedNetCoreAppVersions.Versions.Select(v => $"netcoreapp{v}")
.Should().Contain(targetFramework, $"the {nameof(SupportedNetCoreAppVersions)}.{nameof(SupportedNetCoreAppVersions.Versions)} property should include the default version " +
"of .NET Core created by \"dotnet new\"");
}
[Fact]
public void WeCoverLatestAspNetCoreAppRollForward()
{
var directory = TestAssets.CreateTestDirectory();
string projectDirectory = directory.FullName;
// Run "dotnet new web", get TargetFramework property, and make sure it's covered in SupportedAspNetCoreAppVersions
new NewCommandShim()
.WithWorkingDirectory(projectDirectory)
.Execute("web --no-restore")
.Should().Pass();
string projectPath = Path.Combine(projectDirectory, Path.GetFileName(projectDirectory) + ".csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
string targetFramework = project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework")
.Value;
SupportedAspNetCoreVersions.Versions.Select(v => $"netcoreapp{v}")
.Should().Contain(targetFramework, $"the {nameof(SupportedAspNetCoreVersions)} should include the default version " +
"of Microsoft.AspNetCore.App used by the templates created by \"dotnet new web\"");
}
}
}

View file

@ -36,8 +36,9 @@ namespace EndToEnd.Tests
var runCommand = new RunCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput()
.Should().Pass()
.And.HaveStdOutContaining("Hello World!");
// Templates are still at 3.1 and will not run on 5.0, revert to commented out assertion when 5.0 templates land
//.Should().Pass().And.HaveStdOutContaining("Hello World!");
.Should().Fail().And.HaveStdErrContaining("https://aka.ms/dotnet-core-applaunch");
var binDirectory = new DirectoryInfo(projectDirectory).Sub("bin");
binDirectory.Should().HaveFilesMatching("*.dll", SearchOption.AllDirectories);
@ -79,8 +80,10 @@ namespace EndToEnd.Tests
var runCommand = new RunCommand()
.WithWorkingDirectory(projectDirectory)
.ExecuteWithCapturedOutput()
.Should().Pass()
.And.HaveStdOutContaining("Hello World!");
// Templates are still at 3.1 and will not run on 5.0, revert to commented out assertion when 5.0 templates land
//.Should().Pass().And.HaveStdOutContaining("Hello World!");
.Should().Fail().And.HaveStdErrContaining("https://aka.ms/dotnet-core-applaunch");
}
[Theory]
@ -96,15 +99,15 @@ namespace EndToEnd.Tests
}
[WindowsOnlyTheory]
[InlineData("wpf")]
[InlineData("winforms")]
[InlineData("wpf", Skip = "https://github.com/dotnet/wpf/issues/2363")]
[InlineData("winforms", Skip = "https://github.com/dotnet/wpf/issues/2363")]
public void ItCanBuildDesktopTemplates(string templateName)
{
TestTemplateBuild(templateName);
}
[WindowsOnlyTheory]
[InlineData("wpf")]
[InlineData("wpf", Skip = "https://github.com/dotnet/wpf/issues/2363")]
public void ItCanBuildDesktopTemplatesSelfContained(string templateName)
{
TestTemplateBuild(templateName);

View file

@ -23,6 +23,7 @@ namespace EndToEnd
"2.2",
"3.0",
"3.1",
"5.0"
};
}
}

View file

@ -1,12 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<TargetFramework>netcoreapp5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="FluentAssertions" Version="4.18.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(MicrosoftDotNetPlatformAbstractionsPackageVersion)" />
<PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="$(MicrosoftDotNetCliUtilsPackageVersion)" />
</ItemGroup>
</Project>

View file

@ -0,0 +1,77 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Text.Json;
using System.IO;
using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.TestFramework
{
internal class RuntimeConfigFramework
{
public string Name { get; set; }
public string Version { get; set; }
}
public class RuntimeConfig
{
public bool IsPortable { get; }
internal RuntimeConfigFramework Framework { get; }
public RuntimeConfig(string runtimeConfigPath)
{
var jsonDocumentOptions = new JsonDocumentOptions
{
AllowTrailingCommas = true,
CommentHandling = JsonCommentHandling.Skip
};
using (var stream = File.OpenRead(runtimeConfigPath))
using (JsonDocument doc = JsonDocument.Parse(stream, jsonDocumentOptions))
{
JsonElement root = doc.RootElement;
if (root.TryGetProperty("runtimeOptions", out var runtimeOptionsRoot))
{
if (runtimeOptionsRoot.TryGetProperty("framework", out var framework))
{
var runtimeConfigFramework = new RuntimeConfigFramework();
string name = null;
string version = null;
foreach (var property in framework.EnumerateObject())
{
if (property.Name.Equals("name", StringComparison.OrdinalIgnoreCase))
{
name = property.Value.GetString();
}
if (property.Name.Equals("version", StringComparison.OrdinalIgnoreCase))
{
version = property.Value.GetString();
}
}
if (name == null || version == null)
{
Framework = null;
}
else
{
Framework = new RuntimeConfigFramework
{
Name = name,
Version = version
};
}
}
else
{
Framework = null;
}
}
}
IsPortable = Framework != null;
}
}
}

View file

@ -34,12 +34,17 @@
<SdkTest Include="Build" />
<SdkTest Include="Clean" />
<SdkTest Include="Pack" />
<SdkTest Include="Publish" />
<SdkTest Include="Rebuild" />
<SdkTest Include="Restore" />
<SdkTest Include="ToolPack" />
</ItemGroup>
<!-- Disable Publish tests on Windows x86 until we figure out why they were timing out
https://github.com/dotnet/core-sdk/issues/6285 -->
<ItemGroup Condition="('$(OS)' != 'Windows_NT') Or ('$(Architecture)' != 'x86')">
<SdkTest Include="Publish" />
</ItemGroup>
<Target Name="GetRuntimesToInstall">
<PropertyGroup>
<Supports1xRuntimes>true</Supports1xRuntimes>
@ -87,6 +92,8 @@
<ItemGroup>
<RuntimeVersionToInstall Include="2.1.0" />
<RuntimeVersionToInstall Include="2.2.5" />
<RuntimeVersionToInstall Include="3.0.0" />
<RuntimeVersionToInstall Include="3.1.0-preview1.19506.1" />
</ItemGroup>
</Target>

View file

@ -45,7 +45,7 @@
</TestList>
<SkippedTests>
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToUseVB.It_builds_a_vb_wpf_app"
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToUseVB.It_builds_a_vb_wpf_app"
Skip="true"
Issue="https://github.com/dotnet/wpf/issues/1734"
Reason="VB templates removed from wpf"/>
@ -55,46 +55,10 @@
Issue="https://github.com/dotnet/sdk/pull/3574"
Reason="Test update needed (in PR)"/>
<Method Name="Microsoft.NET.Build.Tests.GivenFrameworkReferences.RuntimeFrameworkVersionCanBeSpecifiedOnFrameworkReference"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3221"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Build.Tests.GivenFrameworkReferences.TargetingPackVersionCanBeSpecifiedOnFrameworkReference"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3221"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Build.Tests.GivenFrameworkReferences.TargetLatestPatchCanBeSpecifiedOnFrameworkReference"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3221"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Build.Tests.GivenFrameworkReferences.TransitiveFrameworkReferenceFromPackageReference"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3221"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Build.Tests.GivenFrameworkReferences.TransitiveFrameworkReferenceFromProjectReference"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3221"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToResolveConflicts.AProjectCanReferenceADllInAPackageDirectly"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3214"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPreserveCompilationContext.It_publishes_the_project_with_a_refs_folder_and_correct_deps_file"
Skip="true"
Issue="https://github.com/dotnet/sdk/pull/3237"
Reason="Code flow needed"/>
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildANetCoreApp.It_targets_the_right_framework_depending_on_output_type"
<!-- <Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildANetCoreApp.It_targets_the_right_framework_depending_on_output_type"
Skip="true"
Issue=""
Reason="Test needs to be updated with new patches (along with SDK stage 0 update)"/>
Reason="Test needs to be updated with new patches (along with SDK stage 0 update)"/> -->
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildAnAppWithLibrariesAndRid.It_builds_a_RID_specific_runnable_output"
Skip="true"
@ -146,20 +110,32 @@
Issue=""
Reason="Needs .NET Core 1.1"/>
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildANetCoreApp.It_runs_a_rid_specific_app_from_the_output_folder"
<!-- <Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildADesktopExeWithFSharp.It_builds_a_simple_desktop_app"
Skip="true"
Issue=""
Reason="Needs .NET Core 2.1.15"/>
Issue="https://github.com/dotnet/coreclr/issues/27275"
Reason="F# compiler is failing on .NET 5 runtime"
/>
<Method Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishASelfContainedApp.It_can_make_a_Windows_GUI_exe"
<Method Name="Microsoft.NET.Build.Tests.GivenThatWeWantToBuildALibraryWithFSharp.It_builds_the_library_successfully"
Skip="true"
Issue=""
Reason="Needs .NET Core 2.1.15"/>
Issue="https://github.com/dotnet/coreclr/issues/27275"
Reason="F# compiler is failing on .NET 5 runtime"
/> -->
<Method Name="Microsoft.NET.Publish.Tests.GivenThatWeWantToPublishAFrameworkDependentApp.It_publishes_with_or_without_apphost"
<Method Name="Microsoft.NET.Publish.Tests.PublishWpfApp.It_publishes_and_runs_self_contained_wpf_app"
Skip="true"
Issue=""
Reason="Needs .NET Core 2.1.15 on Mac OS"/>
Reason="Assumes `dotnet new wpf`produces a netcoreapp3.1 app, will get fixed when sdk takes .NET 5 stage 0"
/>
<Method Name="Microsoft.NET.Build.Tests.GivenWeWantToRequireWindowsForDesktopApps.It_does_not_download_desktop_targeting_packs_on_unix"
Skip="true"
Issue=""
Reason="Assumes netcoreapp3.1 targeting pack is bundled, which it is not in 5.0 SDK. Will resolve when sdk takes newer stage 0 and hits same issue."/>
<Method Name="Microsoft.NET.Build.Tests.GivenWeWantToRequireWindowsForDesktopApps.It_builds_on_windows_with_the_windows_desktop_sdk"
Skip="true"
Issue="https://github.com/dotnet/wpf/issues/2363"
Reason="Desktop SDK missing required files."/>
</SkippedTests>
</Tests>