Merge pull request #10054 from dsplaisted/insert-implicit-aspnet-versions
Insert SDK with implicit ASP.NET versions, add test coverage
This commit is contained in:
commit
559795b616
7 changed files with 192 additions and 303 deletions
|
@ -26,7 +26,7 @@
|
|||
<MicrosoftNETCoreCompilersPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNETCoreCompilersPackageVersion>
|
||||
<MicrosoftCodeAnalysisBuildTasksPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftCodeAnalysisBuildTasksPackageVersion>
|
||||
<MicrosoftNetCompilersNetcorePackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNetCompilersNetcorePackageVersion>
|
||||
<MicrosoftNETSdkPackageVersion>2.2.100-preview1-63215-01</MicrosoftNETSdkPackageVersion>
|
||||
<MicrosoftNETSdkPackageVersion>2.2.100-preview3-63322-01</MicrosoftNETSdkPackageVersion>
|
||||
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
|
||||
<MicrosoftNETSdkRazorPackageVersion>2.1.1</MicrosoftNETSdkRazorPackageVersion>
|
||||
<MicrosoftNETSdkWebPackageVersion>2.2.100-preview3-20180918-2041430</MicrosoftNETSdkWebPackageVersion>
|
||||
|
|
|
@ -158,7 +158,7 @@
|
|||
<ImplicitPackageVariable Include="Microsoft.NETCore.App"
|
||||
TargetFrameworkVersion="2.1"
|
||||
DefaultVersion="2.1.0"
|
||||
LatestVersion="2.1.2" />
|
||||
LatestVersion="2.1.5" />
|
||||
<ImplicitPackageVariable Include="Microsoft.NETCore.App"
|
||||
TargetFrameworkVersion="2.2"
|
||||
DefaultVersion="$(_NETCoreAppPackageVersion)"
|
||||
|
@ -167,11 +167,11 @@
|
|||
<ImplicitPackageVariable Include="Microsoft.AspNetCore.App"
|
||||
TargetFrameworkVersion="2.1"
|
||||
DefaultVersion="2.1.1"
|
||||
LatestVersion="2.1.3"/>
|
||||
LatestVersion="2.1.5"/>
|
||||
<ImplicitPackageVariable Include="Microsoft.AspNetCore.All"
|
||||
TargetFrameworkVersion="2.1"
|
||||
DefaultVersion="2.1.1"
|
||||
LatestVersion="2.1.3"/>
|
||||
LatestVersion="2.1.5"/>
|
||||
<ImplicitPackageVariable Include="Microsoft.AspNetCore.App"
|
||||
TargetFrameworkVersion="2.2"
|
||||
DefaultVersion="$(_AspNetCoreAppPackageVersion)"
|
||||
|
|
|
@ -102,17 +102,17 @@
|
|||
Inputs="@(GenerateSdkMsiInputs)"
|
||||
Outputs="$(SdkInstallerFile)">
|
||||
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateMsiPowershellScript)
|
||||
'$(SdkLayoutOutputDirectory)'
|
||||
'$(SdkInstallerFile)'
|
||||
'$(WixRoot)'
|
||||
'$(SdkBrandName)'
|
||||
'$(MsiVersion)'
|
||||
'$(SimpleVersion)'
|
||||
'$(NugetVersion)'
|
||||
'$(SdkInstallerUpgradeCode)'
|
||||
'$(Architecture)'
|
||||
'$(SdkStableFileIdForApphostTransform)'
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateMsiPowershellScript) ^
|
||||
'$(SdkLayoutOutputDirectory)' ^
|
||||
'$(SdkInstallerFile)' ^
|
||||
'$(WixRoot)' ^
|
||||
'$(SdkBrandName)' ^
|
||||
'$(MsiVersion)' ^
|
||||
'$(SimpleVersion)' ^
|
||||
'$(NugetVersion)' ^
|
||||
'$(SdkInstallerUpgradeCode)' ^
|
||||
'$(Architecture)' ^
|
||||
'$(SdkStableFileIdForApphostTransform)' ^
|
||||
" />
|
||||
</Target>
|
||||
|
||||
|
@ -122,15 +122,15 @@
|
|||
Inputs="@(GenerateMSBuildExtensionsMsiInputs)"
|
||||
Outputs="$(MSBuildExtensionsInstallerFile)">
|
||||
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(MSBuildExtensionsGenerateMsiPowershellScript)
|
||||
'$(MSBuildExtensionsOutputDirectory)'
|
||||
'$(MSBuildExtensionsInstallerFile)'
|
||||
'$(WixRoot)'
|
||||
'$(MSBuildExtensionsBrandName)'
|
||||
'$(SimpleVersion)'
|
||||
'$(SimpleVersion)'
|
||||
'$(NugetVersion)'
|
||||
'$(MSBuildExtensionsInstallerUpgradeCode)'
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(MSBuildExtensionsGenerateMsiPowershellScript) ^
|
||||
'$(MSBuildExtensionsOutputDirectory)' ^
|
||||
'$(MSBuildExtensionsInstallerFile)' ^
|
||||
'$(WixRoot)' ^
|
||||
'$(MSBuildExtensionsBrandName)' ^
|
||||
'$(SimpleVersion)' ^
|
||||
'$(SimpleVersion)' ^
|
||||
'$(NugetVersion)' ^
|
||||
'$(MSBuildExtensionsInstallerUpgradeCode)' ^
|
||||
'$(Architecture)'" />
|
||||
</Target>
|
||||
|
||||
|
@ -144,21 +144,21 @@
|
|||
$(SdkGenerateBundlePowershellScript)"
|
||||
Outputs="$(CombinedFrameworkSdkHostInstallerFile)">
|
||||
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateBundlePowershellScript)
|
||||
'$(SdkInstallerFile)'
|
||||
'$(DownloadedAspNetCoreSharedFxInstallerFile)'
|
||||
'$(DownloadedSharedFrameworkInstallerFile)'
|
||||
'$(DownloadedHostFxrInstallerFile)'
|
||||
'$(DownloadedSharedHostInstallerFile)'
|
||||
'$(CombinedFrameworkSdkHostInstallerFile)'
|
||||
'$(WixRoot)'
|
||||
'$(SdkBrandName)'
|
||||
'$(MsiVersion)'
|
||||
'$(SimpleVersion)'
|
||||
'$(NugetVersion)'
|
||||
'$(CombinedFrameworkSDKHostInstallerUpgradeCode)'
|
||||
'$(Architecture)'
|
||||
'$(MicrosoftNETCoreAppPackageVersion)'
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateBundlePowershellScript) ^
|
||||
'$(SdkInstallerFile)' ^
|
||||
'$(DownloadedAspNetCoreSharedFxInstallerFile)' ^
|
||||
'$(DownloadedSharedFrameworkInstallerFile)' ^
|
||||
'$(DownloadedHostFxrInstallerFile)' ^
|
||||
'$(DownloadedSharedHostInstallerFile)' ^
|
||||
'$(CombinedFrameworkSdkHostInstallerFile)' ^
|
||||
'$(WixRoot)' ^
|
||||
'$(SdkBrandName)' ^
|
||||
'$(MsiVersion)' ^
|
||||
'$(SimpleVersion)' ^
|
||||
'$(NugetVersion)' ^
|
||||
'$(CombinedFrameworkSDKHostInstallerUpgradeCode)' ^
|
||||
'$(Architecture)' ^
|
||||
'$(MicrosoftNETCoreAppPackageVersion)' ^
|
||||
'$(AspNetCoreVersion)'" />
|
||||
</Target>
|
||||
|
||||
|
@ -170,10 +170,10 @@
|
|||
$(SdkGenerateNupkgPowershellScript)"
|
||||
Outputs="$(SdkInstallerNupkgFile)">
|
||||
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript)
|
||||
'$(CombinedFrameworkSdkHostInstallerFile)'
|
||||
'$(FullNugetVersion)'
|
||||
'$(SdkInstallerNuspecFile)'
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript) ^
|
||||
'$(CombinedFrameworkSdkHostInstallerFile)' ^
|
||||
'$(FullNugetVersion)' ^
|
||||
'$(SdkInstallerNuspecFile)' ^
|
||||
'$(SdkInstallerNupkgFile)'" />
|
||||
</Target>
|
||||
|
||||
|
@ -185,10 +185,10 @@
|
|||
$(SdkGenerateNupkgPowershellScript)"
|
||||
Outputs="$(SdkMSBuildExtensionsNupkgFile);$(SdkMSBuildExtensionsSwrFile)">
|
||||
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript)
|
||||
'$(MSBuildExtensionsLayoutDirectory)'
|
||||
'$(FullNugetVersion)'
|
||||
'$(SdkMSBuildExtensionsNuspecFile)'
|
||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript) ^
|
||||
'$(MSBuildExtensionsLayoutDirectory)' ^
|
||||
'$(FullNugetVersion)' ^
|
||||
'$(SdkMSBuildExtensionsNuspecFile)' ^
|
||||
'$(SdkMSBuildExtensionsNupkgFile)'" />
|
||||
|
||||
<GenerateMSBuildExtensionsSWR MSBuildExtensionsLayoutDirectory="$(MSBuildExtensionsLayoutDirectory)"
|
||||
|
@ -202,9 +202,9 @@
|
|||
DependsOnTargets="Init;MsiTargetsSetupInputOutputs;GenerateSdkMsi"
|
||||
Condition=" '$(OS)' == 'Windows_NT'" >
|
||||
|
||||
<Exec Command ="powershell -NoProfile -NoLogo $(SdkTestMsiPowershellScript)
|
||||
-InputMsi '$(SdkInstallerFile)'
|
||||
-DotnetDir '$(PreviousStageDirectory)'
|
||||
<Exec Command ="powershell -NoProfile -NoLogo $(SdkTestMsiPowershellScript) ^
|
||||
-InputMsi '$(SdkInstallerFile)' ^
|
||||
-DotnetDir '$(PreviousStageDirectory)' ^
|
||||
-TestDir '$(TestOutputDir)'" />
|
||||
|
||||
<WriteLinesToFile
|
||||
|
|
|
@ -1,224 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
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 class GivenAspNetAppsResolveImplicitVersions : TestBase
|
||||
{
|
||||
private const string AspNetTestProject = "TestWebAppSimple";
|
||||
|
||||
private const string PinnedAspNetCoreImplicitVersion = "2.1.1";
|
||||
|
||||
[Fact(Skip="https://github.com/dotnet/cli/issues/9687")]
|
||||
public void PortablePublishWithLatestTFMUsesPinnedDownAspNetCoreAppVersion()
|
||||
{
|
||||
var _testInstance = TestAssets.Get(AspNetTestProject)
|
||||
.CreateInstance(identifier: LatestSupportedAspNetCoreAppVersion)
|
||||
.WithSourceFiles();
|
||||
|
||||
string projectDirectory = _testInstance.Root.FullName;
|
||||
string projectPath = Path.Combine(projectDirectory, $"{AspNetTestProject}.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" + LatestSupportedAspNetCoreAppVersion;
|
||||
|
||||
project.Save(projectPath);
|
||||
|
||||
// Get the implicit version
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
||||
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||
|
||||
var restoredVersion = GetAspNetCoreAppVersion(assetsFile, portable: true);
|
||||
restoredVersion.Should().NotBeNull();
|
||||
|
||||
var bundledVersionPath = Path.Combine(projectDirectory, ".DefaultPatchVersionForAspNetCoreApp2_1");
|
||||
var bundledVersion = File.ReadAllText(bundledVersionPath).Trim();
|
||||
|
||||
restoredVersion.ToNormalizedString().Should().BeEquivalentTo(bundledVersion,
|
||||
"The bundled aspnetcore versions set in Microsoft.NETCoreSdk.BundledVersions.props should be identical to the versions generated." +
|
||||
"Please update MSBuildExtensions.targets in this repo so these versions match.");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StandalonePublishWithLatestTFMUsesBundledAspNetCoreAppVersion()
|
||||
{
|
||||
var _testInstance = TestAssets.Get(AspNetTestProject)
|
||||
.CreateInstance(identifier: LatestSupportedAspNetCoreAppVersion)
|
||||
.WithSourceFiles();
|
||||
|
||||
string projectDirectory = _testInstance.Root.FullName;
|
||||
string projectPath = Path.Combine(projectDirectory, $"{AspNetTestProject}.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" + LatestSupportedAspNetCoreAppVersion;
|
||||
|
||||
var rid = Microsoft.DotNet.PlatformAbstractions.RuntimeEnvironment.GetRuntimeIdentifier();
|
||||
|
||||
// Set RuntimeIdentifier to simulate standalone publish
|
||||
project.Root.Element(ns + "PropertyGroup")
|
||||
.Add(new XElement(ns + "RuntimeIdentifier", rid));
|
||||
|
||||
project.Save(projectPath);
|
||||
|
||||
// Get the implicit version
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
||||
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||
|
||||
var restoredVersion = GetAspNetCoreAppVersion(assetsFile);
|
||||
restoredVersion.Should().NotBeNull();
|
||||
|
||||
var bundledVersionPath = Path.Combine(projectDirectory, ".BundledAspNetCoreVersion");
|
||||
var bundledVersion = File.ReadAllText(bundledVersionPath).Trim();
|
||||
|
||||
restoredVersion.ToNormalizedString().Should().BeEquivalentTo(bundledVersion,
|
||||
"The bundled aspnetcore versions set in Microsoft.NETCoreSdk.BundledVersions.props should be identical to the versions set in DependencyVersions.props." +
|
||||
"Please update MSBuildExtensions.targets in this repo so these versions match.");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[MemberData(nameof(SupportedAspNetCoreAppVersions))]
|
||||
public void ItRollsForwardToTheLatestVersion(string minorVersion)
|
||||
{
|
||||
var _testInstance = TestAssets.Get(AspNetTestProject)
|
||||
.CreateInstance(identifier: minorVersion)
|
||||
.WithSourceFiles();
|
||||
|
||||
string projectDirectory = _testInstance.Root.FullName;
|
||||
|
||||
string projectPath = Path.Combine(projectDirectory, $"{AspNetTestProject}.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));
|
||||
|
||||
project.Save(projectPath);
|
||||
|
||||
// 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 = GetAspNetCoreAppVersion(assetsFile);
|
||||
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;
|
||||
}
|
||||
|
||||
// Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
|
||||
Directory.Delete(Path.Combine(projectDirectory, "obj"), true);
|
||||
project.Root.Element(ns + "PropertyGroup")
|
||||
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
|
||||
project.Save(projectPath);
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(projectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
var floatedAssetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||
|
||||
var floatedVersion = GetAspNetCoreAppVersion(floatedAssetsFile);
|
||||
floatedVersion.Should().NotBeNull();
|
||||
|
||||
rolledForwardVersion.ToNormalizedString().Should().BeEquivalentTo(floatedVersion.ToNormalizedString(),
|
||||
"the latest patch version properties in Microsoft.NETCoreSdk.BundledVersions.props need to be updated " +
|
||||
"(see MSBuildExtensions.targets in this repo)");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void WeCoverLatestAspNetCoreAppRollForward()
|
||||
{
|
||||
// Run "dotnet new web", get TargetFramework property, and make sure it's covered in SupportedAspNetCoreAppVersions
|
||||
using (DisposableDirectory directory = Temp.CreateDirectory())
|
||||
{
|
||||
string projectDirectory = directory.Path;
|
||||
|
||||
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;
|
||||
|
||||
SupportedAspNetCoreAppVersions.Select(v => $"netcoreapp{v[0]}")
|
||||
.Should().Contain(targetFramework, $"the {nameof(SupportedAspNetCoreAppVersions)} property should include the default version " +
|
||||
"of Microsoft.AspNetCore.App used by the templates created by \"dotnet new web\"");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private NuGetVersion GetAspNetCoreAppVersion(LockFile lockFile, bool portable = false)
|
||||
{
|
||||
return lockFile?.Targets?.SingleOrDefault(t => portable || t.RuntimeIdentifier != null)
|
||||
?.Libraries?.SingleOrDefault(l =>
|
||||
string.Compare(l.Name, "Microsoft.AspNetCore.App", StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||
?.Version;
|
||||
}
|
||||
|
||||
public static string LatestSupportedAspNetCoreAppVersion = "2.2";
|
||||
|
||||
public static IEnumerable<object[]> SupportedAspNetCoreAppVersions
|
||||
{
|
||||
get
|
||||
{
|
||||
yield return new object[] { LatestSupportedAspNetCoreAppVersion };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -17,10 +17,29 @@ namespace EndToEnd
|
|||
{
|
||||
[Theory]
|
||||
[ClassData(typeof(SupportedNetCoreAppVersions))]
|
||||
public void ItDoesNotRollForwardToTheLatestVersion(string minorVersion)
|
||||
public void ItDoesNotRollForwardToTheLatestVersionOfNetCore(string minorVersion)
|
||||
{
|
||||
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.NETCorePackageName, minorVersion);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(SupportedAspNetCoreVersions))]
|
||||
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreApp(string minorVersion)
|
||||
{
|
||||
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.AspNetCoreAppPackageName, minorVersion);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(SupportedAspNetCoreVersions))]
|
||||
public void ItDoesNotRollForwardToTheLatestVersionOfAspNetCoreAll(string minorVersion)
|
||||
{
|
||||
ItDoesNotRollForwardToTheLatestVersion(GivenSelfContainedAppsRollForward.AspNetCoreAllPackageName, minorVersion);
|
||||
}
|
||||
|
||||
public void ItDoesNotRollForwardToTheLatestVersion(string packageName, string minorVersion)
|
||||
{
|
||||
var _testInstance = TestAssets.Get("TestAppSimple")
|
||||
.CreateInstance(identifier: minorVersion)
|
||||
.CreateInstance(identifier: packageName + "_" + minorVersion)
|
||||
// scope the feed to only dotnet-core feed to avoid flaky when different feed has a newer / lower version
|
||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
|
||||
.WithSourceFiles();
|
||||
|
@ -37,6 +56,13 @@ namespace EndToEnd
|
|||
.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
|
||||
|
@ -48,7 +74,7 @@ namespace EndToEnd
|
|||
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
||||
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||
|
||||
var versionInAssertsJson = GetNetCoreAppVersion(assetsFile);
|
||||
var versionInAssertsJson = GetPackageVersion(assetsFile, packageName);
|
||||
versionInAssertsJson.Should().NotBeNull();
|
||||
|
||||
if (versionInAssertsJson.IsPrerelease && versionInAssertsJson.Patch == 0)
|
||||
|
@ -59,18 +85,18 @@ namespace EndToEnd
|
|||
return;
|
||||
}
|
||||
|
||||
versionInAssertsJson.ToNormalizedString().Should().BeEquivalentTo(GetExpectedVersion(minorVersion));
|
||||
versionInAssertsJson.ToNormalizedString().Should().BeEquivalentTo(GetExpectedVersion(packageName, minorVersion));
|
||||
}
|
||||
|
||||
private NuGetVersion GetNetCoreAppVersion(LockFile lockFile)
|
||||
private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName)
|
||||
{
|
||||
return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier == null)
|
||||
?.Libraries?.SingleOrDefault(l =>
|
||||
string.Compare(l.Name, "Microsoft.NETCore.App", StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||
string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||
?.Version;
|
||||
}
|
||||
|
||||
public string GetExpectedVersion(string minorVersion)
|
||||
public string GetExpectedVersion(string packageName, string minorVersion)
|
||||
{
|
||||
if (minorVersion.StartsWith("1.0"))
|
||||
{
|
||||
|
@ -82,6 +108,16 @@ namespace EndToEnd
|
|||
}
|
||||
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 == GivenSelfContainedAppsRollForward.AspNetCoreAppPackageName ||
|
||||
packageName == GivenSelfContainedAppsRollForward.AspNetCoreAllPackageName)
|
||||
{
|
||||
if (minorVersion == "2.1")
|
||||
{
|
||||
return "2.1.1";
|
||||
}
|
||||
}
|
||||
var parsed = NuGetVersion.Parse(minorVersion);
|
||||
return new NuGetVersion(parsed.Major, parsed.Minor, 0).ToNormalizedString();
|
||||
}
|
||||
|
|
|
@ -14,23 +14,37 @@ 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]
|
||||
// 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 ItRollsForwardToTheLatestVersion(string minorVersion)
|
||||
public void ItRollsForwardToTheLatestNetCoreVersion(string minorVersion)
|
||||
{
|
||||
// https://github.com/dotnet/cli/issues/9661
|
||||
// https://github.com/dotnet/sdk/issues/2446
|
||||
// dotnet/sdk is missing handling for 2.1 when it isn't the latest runtime
|
||||
if (minorVersion == "2.1")
|
||||
{
|
||||
return;
|
||||
}
|
||||
ItRollsForwardToTheLatestVersion(NETCorePackageName, minorVersion);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(SupportedAspNetCoreVersions))]
|
||||
public void ItRollsForwardToTheLatestAspNetCoreAppVersion(string minorVersion)
|
||||
{
|
||||
ItRollsForwardToTheLatestVersion(AspNetCoreAppPackageName, minorVersion);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[ClassData(typeof(SupportedAspNetCoreVersions))]
|
||||
public void ItRollsForwardToTheLatestAspNetCoreAllVersion(string minorVersion)
|
||||
{
|
||||
ItRollsForwardToTheLatestVersion(AspNetCoreAllPackageName, minorVersion);
|
||||
}
|
||||
|
||||
public void ItRollsForwardToTheLatestVersion(string packageName, string minorVersion)
|
||||
{
|
||||
var _testInstance = TestAssets.Get("TestAppSimple")
|
||||
.CreateInstance(identifier: minorVersion)
|
||||
.CreateInstance(identifier: packageName + "_" + minorVersion)
|
||||
.WithSourceFiles();
|
||||
|
||||
string projectDirectory = _testInstance.Root.FullName;
|
||||
|
@ -51,6 +65,13 @@ namespace EndToEnd
|
|||
project.Root.Element(ns + "PropertyGroup")
|
||||
.Add(new XElement(ns + "RuntimeIdentifier", rid));
|
||||
|
||||
if (packageName != 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 version rolled forward to
|
||||
|
@ -62,7 +83,7 @@ namespace EndToEnd
|
|||
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
||||
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||
|
||||
var rolledForwardVersion = GetNetCoreAppVersion(assetsFile);
|
||||
var rolledForwardVersion = GetPackageVersion(assetsFile, packageName);
|
||||
rolledForwardVersion.Should().NotBeNull();
|
||||
|
||||
if (rolledForwardVersion.IsPrerelease)
|
||||
|
@ -74,10 +95,21 @@ namespace EndToEnd
|
|||
return;
|
||||
}
|
||||
|
||||
// Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
|
||||
Directory.Delete(Path.Combine(projectDirectory, "obj"), true);
|
||||
project.Root.Element(ns + "PropertyGroup")
|
||||
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
|
||||
if (packageName == NETCorePackageName)
|
||||
{
|
||||
// Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
|
||||
project.Root.Element(ns + "PropertyGroup")
|
||||
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
|
||||
}
|
||||
else
|
||||
{
|
||||
project.Root.Element(ns + "ItemGroup")
|
||||
.Element(ns + "PackageReference")
|
||||
.Add(new XAttribute("Version", $"{minorVersion}.*"),
|
||||
new XAttribute("AllowExplicitVersion", "true"));
|
||||
}
|
||||
|
||||
project.Save(projectPath);
|
||||
|
||||
new RestoreCommand()
|
||||
|
@ -87,19 +119,19 @@ namespace EndToEnd
|
|||
|
||||
var floatedAssetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||
|
||||
var floatedVersion = GetNetCoreAppVersion(floatedAssetsFile);
|
||||
var floatedVersion = GetPackageVersion(floatedAssetsFile, packageName);
|
||||
floatedVersion.Should().NotBeNull();
|
||||
|
||||
rolledForwardVersion.ToNormalizedString().Should().BeEquivalentTo(floatedVersion.ToNormalizedString(),
|
||||
"the latest patch version properties in Microsoft.NETCoreSdk.BundledVersions.props need to be updated " +
|
||||
"(see MSBuildExtensions.targets in this repo)");
|
||||
$"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 NuGetVersion GetNetCoreAppVersion(LockFile lockFile)
|
||||
private static NuGetVersion GetPackageVersion(LockFile lockFile, string packageName)
|
||||
{
|
||||
return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null)
|
||||
?.Libraries?.SingleOrDefault(l =>
|
||||
string.Compare(l.Name, "Microsoft.NETCore.App", StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||
string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||
?.Version;
|
||||
}
|
||||
|
||||
|
@ -125,11 +157,40 @@ namespace EndToEnd
|
|||
.Element(ns + "TargetFramework")
|
||||
.Value;
|
||||
|
||||
SupportedNetCoreAppVersions.Versions.Select(v => $"netcoreapp{v[0]}")
|
||||
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()
|
||||
{
|
||||
// Run "dotnet new web", get TargetFramework property, and make sure it's covered in SupportedAspNetCoreAppVersions
|
||||
using (DisposableDirectory directory = Temp.CreateDirectory())
|
||||
{
|
||||
string projectDirectory = directory.Path;
|
||||
|
||||
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\"");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,9 @@ namespace EndToEnd
|
|||
{
|
||||
public class SupportedNetCoreAppVersions : IEnumerable<object[]>
|
||||
{
|
||||
public IEnumerator<object[]> GetEnumerator() => Versions.GetEnumerator();
|
||||
public IEnumerator<object[]> GetEnumerator() => Versions.Select(version => new object[] { version }).GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
public static IEnumerable<object[]> Versions
|
||||
public static IEnumerable<string> Versions
|
||||
{
|
||||
get
|
||||
{
|
||||
|
@ -20,7 +20,23 @@ namespace EndToEnd
|
|||
"2.0",
|
||||
"2.1",
|
||||
"2.2"
|
||||
}.Select(version => new object[] { version });
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class SupportedAspNetCoreVersions : IEnumerable<object[]>
|
||||
{
|
||||
public IEnumerator<object[]> GetEnumerator() => Versions.Select(version => new object[] { version }).GetEnumerator();
|
||||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||
|
||||
public static IEnumerable<string> Versions
|
||||
{
|
||||
get
|
||||
{
|
||||
return SupportedNetCoreAppVersions.Versions.Except(new List<string>() { "1.0", "1.1", "2.0" });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue