dotnet-installer/test/EndToEnd/GivenSelfContainedAppsRollForward.cs
dotnet-maestro[bot] 61dd7339c7
[master] Update dependencies from aspnet/AspNetCore (#4391)
* Update dependencies from https://github.com/aspnet/AspNetCore build 20190828.12

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19428.12
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19428.12
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19428.12
- dotnet-watch - 5.0.0-alpha1.19428.12
- dotnet-user-secrets - 5.0.0-alpha1.19428.12
- dotnet-dev-certs - 5.0.0-alpha1.19428.12

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190830.9

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19430.9
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19430.9
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19430.9
- dotnet-watch - 5.0.0-alpha1.19430.9
- dotnet-user-secrets - 5.0.0-alpha1.19430.9
- dotnet-dev-certs - 5.0.0-alpha1.19430.9

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190903.5

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19453.5
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19453.5
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19453.5
- dotnet-watch - 5.0.0-alpha1.19453.5
- dotnet-user-secrets - 5.0.0-alpha1.19453.5
- dotnet-dev-certs - 5.0.0-alpha1.19453.5

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190903.8

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19453.8
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19453.8
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19453.8
- dotnet-watch - 5.0.0-alpha1.19453.8
- dotnet-user-secrets - 5.0.0-alpha1.19453.8
- dotnet-dev-certs - 5.0.0-alpha1.19453.8

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190904.6

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19454.6
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19454.6
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19454.6
- dotnet-watch - 5.0.0-alpha1.19454.6
- dotnet-user-secrets - 5.0.0-alpha1.19454.6
- dotnet-dev-certs - 5.0.0-alpha1.19454.6

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190904.9

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19454.9
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19454.9
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19454.9
- dotnet-watch - 5.0.0-alpha1.19454.9
- dotnet-user-secrets - 5.0.0-alpha1.19454.9
- dotnet-dev-certs - 5.0.0-alpha1.19454.9

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190906.3

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19456.3
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19456.3
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19456.3
- dotnet-watch - 5.0.0-alpha1.19456.3
- dotnet-user-secrets - 5.0.0-alpha1.19456.3
- dotnet-dev-certs - 5.0.0-alpha1.19456.3

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190909.1

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19459.1
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19459.1
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19459.1
- dotnet-watch - 5.0.0-alpha1.19459.1
- dotnet-user-secrets - 5.0.0-alpha1.19459.1
- dotnet-dev-certs - 5.0.0-alpha1.19459.1

* Update 3.0 versions to rc1, update TargetFramework for ASP.NET framework reference

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190909.4

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19459.4
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19459.4
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19459.4
- dotnet-watch - 5.0.0-alpha1.19459.4
- dotnet-user-secrets - 5.0.0-alpha1.19459.4
- dotnet-dev-certs - 5.0.0-alpha1.19459.4

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190911.3

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19461.3
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19461.3
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19461.3
- dotnet-watch - 5.0.0-alpha1.19461.3
- dotnet-user-secrets - 5.0.0-alpha1.19461.3
- dotnet-dev-certs - 5.0.0-alpha1.19461.3

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190911.5

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19461.5
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19461.5
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19461.5
- dotnet-watch - 5.0.0-alpha1.19461.5
- dotnet-user-secrets - 5.0.0-alpha1.19461.5
- dotnet-dev-certs - 5.0.0-alpha1.19461.5

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190911.8

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19461.8
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19461.8
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19461.8
- dotnet-watch - 5.0.0-alpha1.19461.8
- dotnet-user-secrets - 5.0.0-alpha1.19461.8
- dotnet-dev-certs - 5.0.0-alpha1.19461.8

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190911.11

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19461.11
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19461.11
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19461.11
- dotnet-watch - 5.0.0-alpha1.19461.11
- dotnet-user-secrets - 5.0.0-alpha1.19461.11
- dotnet-dev-certs - 5.0.0-alpha1.19461.11

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190911.13

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19461.13
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19461.13
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19461.13
- dotnet-watch - 5.0.0-alpha1.19461.13
- dotnet-user-secrets - 5.0.0-alpha1.19461.13
- dotnet-dev-certs - 5.0.0-alpha1.19461.13

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190912.1

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19462.1
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19462.1
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19462.1
- dotnet-watch - 5.0.0-alpha1.19462.1
- dotnet-user-secrets - 5.0.0-alpha1.19462.1
- dotnet-dev-certs - 5.0.0-alpha1.19462.1

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190912.5

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19462.5
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19462.5
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19462.5
- dotnet-watch - 5.0.0-alpha1.19462.5
- dotnet-user-secrets - 5.0.0-alpha1.19462.5
- dotnet-dev-certs - 5.0.0-alpha1.19462.5

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190912.9

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19462.9
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19462.9
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19462.9
- dotnet-watch - 5.0.0-alpha1.19462.9
- dotnet-user-secrets - 5.0.0-alpha1.19462.9
- dotnet-dev-certs - 5.0.0-alpha1.19462.9

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190916.1

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19466.1
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19466.1
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19466.1
- dotnet-watch - 5.0.0-alpha1.19466.1
- dotnet-user-secrets - 5.0.0-alpha1.19466.1
- dotnet-dev-certs - 5.0.0-alpha1.19466.1

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190916.2

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19466.2
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19466.2
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19466.2
- dotnet-watch - 5.0.0-alpha1.19466.2
- dotnet-user-secrets - 5.0.0-alpha1.19466.2
- dotnet-dev-certs - 5.0.0-alpha1.19466.2

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190916.4

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19466.4
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19466.4
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19466.4
- dotnet-watch - 5.0.0-alpha1.19466.4
- dotnet-user-secrets - 5.0.0-alpha1.19466.4
- dotnet-dev-certs - 5.0.0-alpha1.19466.4

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190916.5

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19466.5
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19466.5
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19466.5
- dotnet-watch - 5.0.0-alpha1.19466.5
- dotnet-user-secrets - 5.0.0-alpha1.19466.5
- dotnet-dev-certs - 5.0.0-alpha1.19466.5

* Update dependencies from https://github.com/aspnet/AspNetCore build 20190916.7

- Microsoft.AspNetCore.DeveloperCertificates.XPlat - 5.0.0-alpha1.19466.7
- Microsoft.AspNetCore.App.Runtime.win-x64 - 5.0.0-alpha1.19466.7
- Microsoft.AspNetCore.App.Ref - 5.0.0-alpha1.19466.7
- dotnet-watch - 5.0.0-alpha1.19466.7
- dotnet-user-secrets - 5.0.0-alpha1.19466.7
- dotnet-dev-certs - 5.0.0-alpha1.19466.7

* Support targeting ASP.NET Core 5.0
2019-09-17 20:09:37 +00:00

195 lines
8 KiB
C#

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 == "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 == "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\"");
}
}
}