dotnet-installer/test/EndToEnd/GivenFrameworkDependentApps.cs
dotnet-maestro[bot] 1a86c899e3
[master] Update dependencies from dotnet/sdk (#8235)
[master] Update dependencies from dotnet/sdk
- Coherency Updates:
  - Microsoft.NETCore.App.Ref: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk)
  - Microsoft.NETCore.App.Internal: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk)
  - Microsoft.NETCore.App.Runtime.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk)
  - Microsoft.NETCore.App.Host.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk)
  - Microsoft.NETCore.DotNetHostResolver: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk)
  - Microsoft.NETCore.Platforms: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk)
  - Microsoft.AspNetCore.App.Ref: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk)
  - Microsoft.AspNetCore.App.Runtime.win-x64: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk)
  - VS.Redist.Common.AspNetCore.TargetingPack.x64.5.0: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk)
  - dotnet-dev-certs: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk)
  - dotnet-user-secrets: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk)
  - dotnet-watch: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk)
  - Microsoft.DotNet.Common.ItemTemplates: from 5.0.0-rc.1.20419.1 to 6.0.0-alpha.1.20454.5 (parent: Microsoft.NET.Sdk)

- Updates:
  - Microsoft.DotNet.MSBuildSdkResolver: from 5.0.100-rc.1.20420.8 to 6.0.100-alpha.1.20454.15
  - Microsoft.NET.Sdk: from 5.0.100-rc.1.20420.8 to 6.0.100-alpha.1.20454.15
  - Microsoft.NETCore.App.Ref: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28
  - Microsoft.NETCore.App.Internal: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28
  - Microsoft.NETCore.App.Runtime.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28
  - Microsoft.NETCore.App.Host.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28
  - Microsoft.NETCore.DotNetHostResolver: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28
  - Microsoft.NETCore.Platforms: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28
  - Microsoft.AspNetCore.App.Ref: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3
  - Microsoft.AspNetCore.App.Runtime.win-x64: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3
  - VS.Redist.Common.AspNetCore.TargetingPack.x64.5.0: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3
  - dotnet-dev-certs: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3
  - dotnet-user-secrets: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3
  - dotnet-watch: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3
  - Microsoft.DotNet.Common.ItemTemplates: from 5.0.0-rc.1.20419.1 to 6.0.0-alpha.1.20454.5

 - Update NuGet.config

 - Updates for 6.0 runtime

 - Reenabling test

 - Fixup toolset base url
2020-09-04 22:28:24 +00:00

120 lines
4.7 KiB
C#

// 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.IO;
using System.Linq;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.ProjectModel;
using NuGet.Versioning;
using Xunit;
namespace EndToEnd
{
public class GivenFrameworkDependentApps : TestBase
{
[Theory]
[ClassData(typeof(SupportedNetCoreAppVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfNetCore(string minorVersion)
{
if (minorVersion == "3.0" || minorVersion == "3.1" || minorVersion == "5.0" || minorVersion == "6.0")
{
// https://github.com/dotnet/core-sdk/issues/621
return;
}
ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.NETCorePackageName, minorVersion);
}
[Theory]
[ClassData(typeof(SupportedAspNetCoreVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreApp(string minorVersion)
{
if (minorVersion == "3.0" || minorVersion == "3.1" || minorVersion == "5.0" || minorVersion == "6.0")
{
// https://github.com/dotnet/core-sdk/issues/621
return;
}
ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAppPackageName, minorVersion);
}
[Theory]
[ClassData(typeof(SupportedAspNetCoreAllVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion)
{
ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion);
}
internal void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion)
{
var testProjectCreator = new TestProjectCreator()
{
PackageName = packageName,
MinorVersion = minorVersion,
};
var _testInstance = testProjectCreator.Create();
string projectDirectory = _testInstance.Root.FullName;
string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj");
// Get the resolved version of .NET Core
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.Execute()
.Should().Pass();
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
var assetsFile = new LockFileFormat().Read(assetsFilePath);
var versionInAssertsJson = GetPackageVersion(assetsFile, packageName);
versionInAssertsJson.Should().NotBeNull();
if (versionInAssertsJson.IsPrerelease && versionInAssertsJson.Patch == 0)
{
// if the bundled version is, for example, a prerelease of
// .NET Core 2.1.1, that we don't roll forward to that prerelease
// version for framework-dependent deployments.
return;
}
versionInAssertsJson.ToNormalizedString().Should().BeEquivalentTo(GetExpectedVersion(packageName, minorVersion));
}
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;
}
public string GetExpectedVersion(string packageName, string minorVersion)
{
if (minorVersion.StartsWith("1.0"))
{
return "1.0.5"; // special case for 1.0
}
else if (minorVersion.StartsWith("1.1"))
{
return "1.1.2"; // special case for 1.1
}
else
{
// ASP.NET 2.1.0 packages had exact version dependencies, which was problematic,
// so the default version for 2.1 apps is 2.1.1.
if (packageName == TestProjectCreator.AspNetCoreAppPackageName ||
packageName == TestProjectCreator.AspNetCoreAllPackageName)
{
if (minorVersion == "2.1")
{
return "2.1.1";
}
}
var parsed = NuGetVersion.Parse(minorVersion);
return new NuGetVersion(parsed.Major, parsed.Minor, 0).ToNormalizedString();
}
}
}
}