Merge upstream changes

This commit is contained in:
Daniel Plaisted 2018-11-09 15:22:10 -08:00
commit e13e5fca99
8 changed files with 154 additions and 81 deletions

View file

@ -4,7 +4,7 @@
<MicrosoftDotNetCliUtilsPackageVersion>3.0.100-alpha1-20180711-1</MicrosoftDotNetCliUtilsPackageVersion> <MicrosoftDotNetCliUtilsPackageVersion>3.0.100-alpha1-20180711-1</MicrosoftDotNetCliUtilsPackageVersion>
<MicrosoftDotNetCliCommandLinePackageVersion>0.1.1</MicrosoftDotNetCliCommandLinePackageVersion> <MicrosoftDotNetCliCommandLinePackageVersion>0.1.1</MicrosoftDotNetCliCommandLinePackageVersion>
<MicrosoftNETTestSdkPackageVersion>15.8.0</MicrosoftNETTestSdkPackageVersion> <MicrosoftNETTestSdkPackageVersion>15.8.0</MicrosoftNETTestSdkPackageVersion>
<MicrosoftDotNetPlatformAbstractionsPackageVersion>3.0.0-preview-27106-02</MicrosoftDotNetPlatformAbstractionsPackageVersion> <MicrosoftDotNetPlatformAbstractionsPackageVersion>3.0.0-preview-27109-05</MicrosoftDotNetPlatformAbstractionsPackageVersion>
<MicrosoftDotNetProjectJsonMigrationPackageVersion>1.3.1</MicrosoftDotNetProjectJsonMigrationPackageVersion> <MicrosoftDotNetProjectJsonMigrationPackageVersion>1.3.1</MicrosoftDotNetProjectJsonMigrationPackageVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View file

@ -17,7 +17,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<MicrosoftNETCoreAppPackageVersion>3.0.0-preview-27106-02</MicrosoftNETCoreAppPackageVersion> <MicrosoftNETCoreAppPackageVersion>3.0.0-preview-27109-05</MicrosoftNETCoreAppPackageVersion>
<MicrosoftNETCoreDotNetHostResolverPackageVersion>$(MicrosoftNETCoreAppPackageVersion)</MicrosoftNETCoreDotNetHostResolverPackageVersion> <MicrosoftNETCoreDotNetHostResolverPackageVersion>$(MicrosoftNETCoreAppPackageVersion)</MicrosoftNETCoreDotNetHostResolverPackageVersion>
</PropertyGroup> </PropertyGroup>

View file

@ -74,7 +74,7 @@
<ImplicitPackageVariable Include="Microsoft.NETCore.App" <ImplicitPackageVariable Include="Microsoft.NETCore.App"
TargetFrameworkVersion="2.1" TargetFrameworkVersion="2.1"
DefaultVersion="2.1.0" DefaultVersion="2.1.0"
LatestVersion="2.1.5" /> LatestVersion="2.1.6" />
<ImplicitPackageVariable Include="Microsoft.NETCore.App" <ImplicitPackageVariable Include="Microsoft.NETCore.App"
TargetFrameworkVersion="3.0" TargetFrameworkVersion="3.0"
DefaultVersion="$(_NETCoreAppPackageVersion)" DefaultVersion="$(_NETCoreAppPackageVersion)"
@ -83,11 +83,11 @@
<ImplicitPackageVariable Include="Microsoft.AspNetCore.App" <ImplicitPackageVariable Include="Microsoft.AspNetCore.App"
TargetFrameworkVersion="2.1" TargetFrameworkVersion="2.1"
DefaultVersion="2.1.1" DefaultVersion="2.1.1"
LatestVersion="2.1.5"/> LatestVersion="2.1.6"/>
<ImplicitPackageVariable Include="Microsoft.AspNetCore.All" <ImplicitPackageVariable Include="Microsoft.AspNetCore.All"
TargetFrameworkVersion="2.1" TargetFrameworkVersion="2.1"
DefaultVersion="2.1.1" DefaultVersion="2.1.1"
LatestVersion="2.1.5"/> LatestVersion="2.1.6"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -164,7 +164,7 @@ Copyright (c) .NET Foundation. All rights reserved.
TargetingPackVersion="$(MicrosoftDesktopUIPackageVersion)" TargetingPackVersion="$(MicrosoftDesktopUIPackageVersion)"
/> />
<KnownFrameworkReference Include="Microsoft.AspNetCore" <KnownFrameworkReference Include="Microsoft.AspNetCore.App"
TargetFramework="netcoreapp3.0" TargetFramework="netcoreapp3.0"
RuntimeFrameworkName="Microsoft.AspNetCore.App" RuntimeFrameworkName="Microsoft.AspNetCore.App"
DefaultRuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppPackageVersion)" DefaultRuntimeFrameworkVersion="$(MicrosoftAspNetCoreAppPackageVersion)"

View file

@ -19,50 +19,37 @@ namespace EndToEnd
[ClassData(typeof(SupportedNetCoreAppVersions))] [ClassData(typeof(SupportedNetCoreAppVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfNetCore(string minorVersion) public void ItDoesNotRollForwardToTheLatestVersionOfNetCore(string minorVersion)
{ {
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.NETCorePackageName, minorVersion); ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.NETCorePackageName, minorVersion);
} }
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")] [Theory]
[ClassData(typeof(SupportedAspNetCoreVersions))] [ClassData(typeof(SupportedAspNetCoreVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreApp(string minorVersion) public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreApp(string minorVersion)
{ {
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.AspNetCoreAppPackageName, minorVersion); ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAppPackageName, minorVersion);
} }
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")] [Theory]
[ClassData(typeof(SupportedAspNetCoreVersions))] [ClassData(typeof(SupportedAspNetCoreAllVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion) public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion)
{ {
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.AspNetCoreAllPackageName, minorVersion); ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion);
} }
internal void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion) internal void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion)
{ {
var _testInstance = TestAssets.Get("TestAppSimple") var testProjectCreator = new TestProjectCreator()
.CreateInstance(identifier: packageName + "_" + minorVersion) {
.WithSourceFiles(); PackageName = packageName,
MinorVersion = minorVersion,
};
var _testInstance = testProjectCreator.Create();
string projectDirectory = _testInstance.Root.FullName; string projectDirectory = _testInstance.Root.FullName;
string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj"); string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
// Update TargetFramework to the right version of .NET Core
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework")
.Value = "netcoreapp" + minorVersion;
if (packageName != GivenSelfContainedAppsRollForward.NETCorePackageName)
{
// Add implicit ASP.NET reference
project.Root.Add(new XElement(ns + "ItemGroup",
new XElement(ns + "PackageReference", new XAttribute("Include", packageName))));
}
project.Save(projectPath);
// Get the resolved version of .NET Core // Get the resolved version of .NET Core
new RestoreCommand() new RestoreCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(projectDirectory)
@ -108,8 +95,8 @@ namespace EndToEnd
{ {
// ASP.NET 2.1.0 packages had exact version dependencies, which was problematic, // 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. // so the default version for 2.1 apps is 2.1.1.
if (packageName == GivenSelfContainedAppsRollForward.AspNetCoreAppPackageName || if (packageName == TestProjectCreator.AspNetCoreAppPackageName ||
packageName == GivenSelfContainedAppsRollForward.AspNetCoreAllPackageName) packageName == TestProjectCreator.AspNetCoreAllPackageName)
{ {
if (minorVersion == "2.1") if (minorVersion == "2.1")
{ {

View file

@ -16,65 +16,43 @@ namespace EndToEnd
{ {
public partial class GivenSelfContainedAppsRollForward : TestBase public partial class GivenSelfContainedAppsRollForward : TestBase
{ {
public const string NETCorePackageName = "Microsoft.NETCore.App";
public const string AspNetCoreAppPackageName = "Microsoft.AspNetCore.App";
public const string AspNetCoreAllPackageName = "Microsoft.AspNetCore.All";
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")] [Theory]
// MemberData is used instead of InlineData here so we can access it in another test to // 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 // verify that we are covering the latest release of .NET Core
[ClassData(typeof(SupportedNetCoreAppVersions))] [ClassData(typeof(SupportedNetCoreAppVersions))]
public void ItRollsForwardToTheLatestNetCoreVersion(string minorVersion) public void ItRollsForwardToTheLatestNetCoreVersion(string minorVersion)
{ {
ItRollsForwardToTheLatestVersion(NETCorePackageName, minorVersion); ItRollsForwardToTheLatestVersion(TestProjectCreator.NETCorePackageName, minorVersion);
} }
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")] [Theory]
[ClassData(typeof(SupportedAspNetCoreVersions))] [ClassData(typeof(SupportedAspNetCoreVersions))]
public void ItRollsForwardToTheLatestAspNetCoreAppVersion(string minorVersion) public void ItRollsForwardToTheLatestAspNetCoreAppVersion(string minorVersion)
{ {
ItRollsForwardToTheLatestVersion(AspNetCoreAppPackageName, minorVersion); ItRollsForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAppPackageName, minorVersion);
} }
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")] [Theory]
[ClassData(typeof(SupportedAspNetCoreVersions))] [ClassData(typeof(SupportedAspNetCoreAllVersions))]
public void ItRollsForwardToTheLatestAspNetCoreAllVersion(string minorVersion) public void ItRollsForwardToTheLatestAspNetCoreAllVersion(string minorVersion)
{ {
ItRollsForwardToTheLatestVersion(AspNetCoreAllPackageName, minorVersion); ItRollsForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion);
} }
internal void ItRollsForwardToTheLatestVersion(string packageName, string minorVersion) internal void ItRollsForwardToTheLatestVersion(string packageName, string minorVersion)
{ {
var _testInstance = TestAssets.Get("TestAppSimple") var testProjectCreator = new TestProjectCreator()
.CreateInstance(identifier: packageName + "_" + minorVersion)
.WithSourceFiles();
string projectDirectory = _testInstance.Root.FullName;
string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
// Update TargetFramework to the right version of .NET Core
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework")
.Value = "netcoreapp" + minorVersion;
var rid = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier();
// Set RuntimeIdentifier to opt in to roll-forward behavior
project.Root.Element(ns + "PropertyGroup")
.Add(new XElement(ns + "RuntimeIdentifier", rid));
if (packageName != NETCorePackageName)
{ {
// Add implicit ASP.NET reference PackageName = packageName,
project.Root.Add(new XElement(ns + "ItemGroup", MinorVersion = minorVersion,
new XElement(ns + "PackageReference", new XAttribute("Include", packageName)))); // Set RuntimeIdentifier to opt in to roll-forward behavior
} RuntimeIdentifier = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()
};
project.Save(projectPath); var testInstance = testProjectCreator.Create();
string projectDirectory = testInstance.Root.FullName;
// Get the version rolled forward to // Get the version rolled forward to
new RestoreCommand() new RestoreCommand()
@ -97,29 +75,40 @@ namespace EndToEnd
return; return;
} }
Directory.Delete(Path.Combine(projectDirectory, "obj"), true); testProjectCreator.Identifier = "floating";
if (packageName == NETCorePackageName)
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 // Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
project.Root.Element(ns + "PropertyGroup") floatingProject.Root.Element(ns + "PropertyGroup")
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*")); .Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
} }
else else
{ {
project.Root.Element(ns + "ItemGroup") floatingProject.Root.Element(ns + "ItemGroup")
.Element(ns + "PackageReference") .Element(ns + "PackageReference")
.Add(new XAttribute("Version", $"{minorVersion}.*"), .Add(new XAttribute("Version", $"{minorVersion}.*"),
new XAttribute("AllowExplicitVersion", "true")); new XAttribute("AllowExplicitVersion", "true"));
} }
project.Save(projectPath); floatingProject.Save(floatingProjectPath);
new RestoreCommand() new RestoreCommand()
.WithWorkingDirectory(projectDirectory) .WithWorkingDirectory(floatingProjectInstance.Root.FullName)
.Execute() .Execute()
.Should().Pass(); .Should().Pass();
var floatedAssetsFile = new LockFileFormat().Read(assetsFilePath); string floatingAssetsFilePath = Path.Combine(floatingProjectInstance.Root.FullName, "obj", "project.assets.json");
var floatedAssetsFile = new LockFileFormat().Read(floatingAssetsFilePath);
var floatedVersion = GetPackageVersion(floatedAssetsFile, packageName); var floatedVersion = GetPackageVersion(floatedAssetsFile, packageName);
floatedVersion.Should().NotBeNull(); floatedVersion.Should().NotBeNull();

View file

@ -1,4 +1,5 @@
using System.Collections; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Xunit; using Xunit;
@ -19,6 +20,8 @@ namespace EndToEnd
"1.1", "1.1",
"2.0", "2.0",
"2.1", "2.1",
// 2.2 currently disabled in master: https://github.com/dotnet/cli/issues/10125
// "2.2",
"3.0" "3.0"
}; };
} }
@ -40,4 +43,18 @@ namespace EndToEnd
} }
} }
} }
public class SupportedAspNetCoreAllVersions : IEnumerable<object[]>
{
public IEnumerator<object[]> GetEnumerator() => Versions.Select(version => new object[] { version }).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
public static IEnumerable<string> Versions
{
get
{
return SupportedAspNetCoreVersions.Versions.Where(v => new Version(v).Major < 3);
}
}
}
} }

View file

@ -0,0 +1,80 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Xml.Linq;
using Microsoft.DotNet.TestFramework;
using Microsoft.DotNet.Tools.Test.Utilities;
namespace EndToEnd
{
class TestProjectCreator
{
public const string NETCorePackageName = "Microsoft.NETCore.App";
public const string AspNetCoreAppPackageName = "Microsoft.AspNetCore.App";
public const string AspNetCoreAllPackageName = "Microsoft.AspNetCore.All";
public string TestName { get; set; }
public string Identifier { get; set; }
public string PackageName { get; set; } = NETCorePackageName;
public string MinorVersion { get; set; }
public string RuntimeIdentifier { get; set; }
public TestProjectCreator([CallerMemberName] string testName = null, string identifier = "")
{
TestName = testName;
Identifier = identifier;
}
public TestAssetInstance Create()
{
var testInstance = TestBase.TestAssets.Get("TestAppSimple")
.CreateInstance(callingMethod: TestName, identifier: Identifier + PackageName + "_" + MinorVersion)
.WithSourceFiles();
string projectDirectory = testInstance.Root.FullName;
string projectPath = Path.Combine(projectDirectory, "TestAppSimple.csproj");
var project = XDocument.Load(projectPath);
var ns = project.Root.Name.Namespace;
// Update TargetFramework to the right version of .NET Core
project.Root.Element(ns + "PropertyGroup")
.Element(ns + "TargetFramework")
.Value = "netcoreapp" + MinorVersion;
if (!string.IsNullOrEmpty(RuntimeIdentifier))
{
project.Root.Element(ns + "PropertyGroup")
.Add(new XElement(ns + "RuntimeIdentifier", RuntimeIdentifier));
}
if (PackageName != NETCorePackageName)
{
if (new Version(MinorVersion).Major < 3)
{
// Add ASP.NET PackageReference with implicit version for target framework versions prior to 3.0
project.Root.Add(new XElement(ns + "ItemGroup",
new XElement(ns + "PackageReference", new XAttribute("Include", PackageName))));
}
else
{
project.Root.Add(new XElement(ns + "ItemGroup",
new XElement(ns + "FrameworkReference", new XAttribute("Include", PackageName))));
}
}
project.Save(projectPath);
return testInstance;
}
}
}

View file

@ -42,7 +42,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
} }
} }
protected static TestAssets TestAssets public static TestAssets TestAssets
{ {
get get
{ {