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>
<MicrosoftDotNetCliCommandLinePackageVersion>0.1.1</MicrosoftDotNetCliCommandLinePackageVersion>
<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>
</PropertyGroup>
</Project>

View file

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

View file

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

View file

@ -19,50 +19,37 @@ namespace EndToEnd
[ClassData(typeof(SupportedNetCoreAppVersions))]
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))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreApp(string minorVersion)
{
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.AspNetCoreAppPackageName, minorVersion);
ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAppPackageName, minorVersion);
}
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")]
[ClassData(typeof(SupportedAspNetCoreVersions))]
[Theory]
[ClassData(typeof(SupportedAspNetCoreAllVersions))]
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion)
{
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.AspNetCoreAllPackageName, minorVersion);
ItDoesNotRollForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion);
}
internal void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion)
{
var _testInstance = TestAssets.Get("TestAppSimple")
.CreateInstance(identifier: packageName + "_" + minorVersion)
.WithSourceFiles();
var testProjectCreator = new TestProjectCreator()
{
PackageName = packageName,
MinorVersion = minorVersion,
};
var _testInstance = testProjectCreator.Create();
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 (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
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
@ -108,8 +95,8 @@ namespace EndToEnd
{
// 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 == GivenSelfContainedAppsRollForward.AspNetCoreAppPackageName ||
packageName == GivenSelfContainedAppsRollForward.AspNetCoreAllPackageName)
if (packageName == TestProjectCreator.AspNetCoreAppPackageName ||
packageName == TestProjectCreator.AspNetCoreAllPackageName)
{
if (minorVersion == "2.1")
{

View file

@ -16,65 +16,43 @@ namespace EndToEnd
{
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
// verify that we are covering the latest release of .NET Core
[ClassData(typeof(SupportedNetCoreAppVersions))]
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))]
public void ItRollsForwardToTheLatestAspNetCoreAppVersion(string minorVersion)
{
ItRollsForwardToTheLatestVersion(AspNetCoreAppPackageName, minorVersion);
ItRollsForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAppPackageName, minorVersion);
}
[Theory(Skip = "https://github.com/dotnet/cli/issues/10123")]
[ClassData(typeof(SupportedAspNetCoreVersions))]
[Theory]
[ClassData(typeof(SupportedAspNetCoreAllVersions))]
public void ItRollsForwardToTheLatestAspNetCoreAllVersion(string minorVersion)
{
ItRollsForwardToTheLatestVersion(AspNetCoreAllPackageName, minorVersion);
ItRollsForwardToTheLatestVersion(TestProjectCreator.AspNetCoreAllPackageName, minorVersion);
}
internal void ItRollsForwardToTheLatestVersion(string packageName, string minorVersion)
{
var _testInstance = TestAssets.Get("TestAppSimple")
.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)
var testProjectCreator = new TestProjectCreator()
{
// Add implicit ASP.NET reference
project.Root.Add(new XElement(ns + "ItemGroup",
new XElement(ns + "PackageReference", new XAttribute("Include", packageName))));
}
PackageName = packageName,
MinorVersion = minorVersion,
// 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
new RestoreCommand()
@ -97,29 +75,40 @@ namespace EndToEnd
return;
}
Directory.Delete(Path.Combine(projectDirectory, "obj"), true);
if (packageName == NETCorePackageName)
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
project.Root.Element(ns + "PropertyGroup")
floatingProject.Root.Element(ns + "PropertyGroup")
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
}
else
{
project.Root.Element(ns + "ItemGroup")
floatingProject.Root.Element(ns + "ItemGroup")
.Element(ns + "PackageReference")
.Add(new XAttribute("Version", $"{minorVersion}.*"),
new XAttribute("AllowExplicitVersion", "true"));
}
project.Save(projectPath);
floatingProject.Save(floatingProjectPath);
new RestoreCommand()
.WithWorkingDirectory(projectDirectory)
.WithWorkingDirectory(floatingProjectInstance.Root.FullName)
.Execute()
.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);
floatedVersion.Should().NotBeNull();

View file

@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Xunit;
@ -19,6 +20,8 @@ namespace EndToEnd
"1.1",
"2.0",
"2.1",
// 2.2 currently disabled in master: https://github.com/dotnet/cli/issues/10125
// "2.2",
"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
{