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>
|
<MicrosoftNETCoreCompilersPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNETCoreCompilersPackageVersion>
|
||||||
<MicrosoftCodeAnalysisBuildTasksPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftCodeAnalysisBuildTasksPackageVersion>
|
<MicrosoftCodeAnalysisBuildTasksPackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftCodeAnalysisBuildTasksPackageVersion>
|
||||||
<MicrosoftNetCompilersNetcorePackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNetCompilersNetcorePackageVersion>
|
<MicrosoftNetCompilersNetcorePackageVersion>$(MicrosoftCodeAnalysisCSharpPackageVersion)</MicrosoftNetCompilersNetcorePackageVersion>
|
||||||
<MicrosoftNETSdkPackageVersion>2.2.100-preview1-63215-01</MicrosoftNETSdkPackageVersion>
|
<MicrosoftNETSdkPackageVersion>2.2.100-preview3-63322-01</MicrosoftNETSdkPackageVersion>
|
||||||
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
|
<MicrosoftNETBuildExtensionsPackageVersion>$(MicrosoftNETSdkPackageVersion)</MicrosoftNETBuildExtensionsPackageVersion>
|
||||||
<MicrosoftNETSdkRazorPackageVersion>2.1.1</MicrosoftNETSdkRazorPackageVersion>
|
<MicrosoftNETSdkRazorPackageVersion>2.1.1</MicrosoftNETSdkRazorPackageVersion>
|
||||||
<MicrosoftNETSdkWebPackageVersion>2.2.100-preview3-20180918-2041430</MicrosoftNETSdkWebPackageVersion>
|
<MicrosoftNETSdkWebPackageVersion>2.2.100-preview3-20180918-2041430</MicrosoftNETSdkWebPackageVersion>
|
||||||
|
|
|
@ -158,7 +158,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.2" />
|
LatestVersion="2.1.5" />
|
||||||
<ImplicitPackageVariable Include="Microsoft.NETCore.App"
|
<ImplicitPackageVariable Include="Microsoft.NETCore.App"
|
||||||
TargetFrameworkVersion="2.2"
|
TargetFrameworkVersion="2.2"
|
||||||
DefaultVersion="$(_NETCoreAppPackageVersion)"
|
DefaultVersion="$(_NETCoreAppPackageVersion)"
|
||||||
|
@ -167,11 +167,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.3"/>
|
LatestVersion="2.1.5"/>
|
||||||
<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.3"/>
|
LatestVersion="2.1.5"/>
|
||||||
<ImplicitPackageVariable Include="Microsoft.AspNetCore.App"
|
<ImplicitPackageVariable Include="Microsoft.AspNetCore.App"
|
||||||
TargetFrameworkVersion="2.2"
|
TargetFrameworkVersion="2.2"
|
||||||
DefaultVersion="$(_AspNetCoreAppPackageVersion)"
|
DefaultVersion="$(_AspNetCoreAppPackageVersion)"
|
||||||
|
|
|
@ -102,17 +102,17 @@
|
||||||
Inputs="@(GenerateSdkMsiInputs)"
|
Inputs="@(GenerateSdkMsiInputs)"
|
||||||
Outputs="$(SdkInstallerFile)">
|
Outputs="$(SdkInstallerFile)">
|
||||||
|
|
||||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateMsiPowershellScript)
|
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateMsiPowershellScript) ^
|
||||||
'$(SdkLayoutOutputDirectory)'
|
'$(SdkLayoutOutputDirectory)' ^
|
||||||
'$(SdkInstallerFile)'
|
'$(SdkInstallerFile)' ^
|
||||||
'$(WixRoot)'
|
'$(WixRoot)' ^
|
||||||
'$(SdkBrandName)'
|
'$(SdkBrandName)' ^
|
||||||
'$(MsiVersion)'
|
'$(MsiVersion)' ^
|
||||||
'$(SimpleVersion)'
|
'$(SimpleVersion)' ^
|
||||||
'$(NugetVersion)'
|
'$(NugetVersion)' ^
|
||||||
'$(SdkInstallerUpgradeCode)'
|
'$(SdkInstallerUpgradeCode)' ^
|
||||||
'$(Architecture)'
|
'$(Architecture)' ^
|
||||||
'$(SdkStableFileIdForApphostTransform)'
|
'$(SdkStableFileIdForApphostTransform)' ^
|
||||||
" />
|
" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
@ -122,15 +122,15 @@
|
||||||
Inputs="@(GenerateMSBuildExtensionsMsiInputs)"
|
Inputs="@(GenerateMSBuildExtensionsMsiInputs)"
|
||||||
Outputs="$(MSBuildExtensionsInstallerFile)">
|
Outputs="$(MSBuildExtensionsInstallerFile)">
|
||||||
|
|
||||||
<Exec Command="powershell -NoProfile -NoLogo $(MSBuildExtensionsGenerateMsiPowershellScript)
|
<Exec Command="powershell -NoProfile -NoLogo $(MSBuildExtensionsGenerateMsiPowershellScript) ^
|
||||||
'$(MSBuildExtensionsOutputDirectory)'
|
'$(MSBuildExtensionsOutputDirectory)' ^
|
||||||
'$(MSBuildExtensionsInstallerFile)'
|
'$(MSBuildExtensionsInstallerFile)' ^
|
||||||
'$(WixRoot)'
|
'$(WixRoot)' ^
|
||||||
'$(MSBuildExtensionsBrandName)'
|
'$(MSBuildExtensionsBrandName)' ^
|
||||||
'$(SimpleVersion)'
|
'$(SimpleVersion)' ^
|
||||||
'$(SimpleVersion)'
|
'$(SimpleVersion)' ^
|
||||||
'$(NugetVersion)'
|
'$(NugetVersion)' ^
|
||||||
'$(MSBuildExtensionsInstallerUpgradeCode)'
|
'$(MSBuildExtensionsInstallerUpgradeCode)' ^
|
||||||
'$(Architecture)'" />
|
'$(Architecture)'" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
@ -144,21 +144,21 @@
|
||||||
$(SdkGenerateBundlePowershellScript)"
|
$(SdkGenerateBundlePowershellScript)"
|
||||||
Outputs="$(CombinedFrameworkSdkHostInstallerFile)">
|
Outputs="$(CombinedFrameworkSdkHostInstallerFile)">
|
||||||
|
|
||||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateBundlePowershellScript)
|
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateBundlePowershellScript) ^
|
||||||
'$(SdkInstallerFile)'
|
'$(SdkInstallerFile)' ^
|
||||||
'$(DownloadedAspNetCoreSharedFxInstallerFile)'
|
'$(DownloadedAspNetCoreSharedFxInstallerFile)' ^
|
||||||
'$(DownloadedSharedFrameworkInstallerFile)'
|
'$(DownloadedSharedFrameworkInstallerFile)' ^
|
||||||
'$(DownloadedHostFxrInstallerFile)'
|
'$(DownloadedHostFxrInstallerFile)' ^
|
||||||
'$(DownloadedSharedHostInstallerFile)'
|
'$(DownloadedSharedHostInstallerFile)' ^
|
||||||
'$(CombinedFrameworkSdkHostInstallerFile)'
|
'$(CombinedFrameworkSdkHostInstallerFile)' ^
|
||||||
'$(WixRoot)'
|
'$(WixRoot)' ^
|
||||||
'$(SdkBrandName)'
|
'$(SdkBrandName)' ^
|
||||||
'$(MsiVersion)'
|
'$(MsiVersion)' ^
|
||||||
'$(SimpleVersion)'
|
'$(SimpleVersion)' ^
|
||||||
'$(NugetVersion)'
|
'$(NugetVersion)' ^
|
||||||
'$(CombinedFrameworkSDKHostInstallerUpgradeCode)'
|
'$(CombinedFrameworkSDKHostInstallerUpgradeCode)' ^
|
||||||
'$(Architecture)'
|
'$(Architecture)' ^
|
||||||
'$(MicrosoftNETCoreAppPackageVersion)'
|
'$(MicrosoftNETCoreAppPackageVersion)' ^
|
||||||
'$(AspNetCoreVersion)'" />
|
'$(AspNetCoreVersion)'" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
@ -170,10 +170,10 @@
|
||||||
$(SdkGenerateNupkgPowershellScript)"
|
$(SdkGenerateNupkgPowershellScript)"
|
||||||
Outputs="$(SdkInstallerNupkgFile)">
|
Outputs="$(SdkInstallerNupkgFile)">
|
||||||
|
|
||||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript)
|
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript) ^
|
||||||
'$(CombinedFrameworkSdkHostInstallerFile)'
|
'$(CombinedFrameworkSdkHostInstallerFile)' ^
|
||||||
'$(FullNugetVersion)'
|
'$(FullNugetVersion)' ^
|
||||||
'$(SdkInstallerNuspecFile)'
|
'$(SdkInstallerNuspecFile)' ^
|
||||||
'$(SdkInstallerNupkgFile)'" />
|
'$(SdkInstallerNupkgFile)'" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
@ -185,10 +185,10 @@
|
||||||
$(SdkGenerateNupkgPowershellScript)"
|
$(SdkGenerateNupkgPowershellScript)"
|
||||||
Outputs="$(SdkMSBuildExtensionsNupkgFile);$(SdkMSBuildExtensionsSwrFile)">
|
Outputs="$(SdkMSBuildExtensionsNupkgFile);$(SdkMSBuildExtensionsSwrFile)">
|
||||||
|
|
||||||
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript)
|
<Exec Command="powershell -NoProfile -NoLogo $(SdkGenerateNupkgPowershellScript) ^
|
||||||
'$(MSBuildExtensionsLayoutDirectory)'
|
'$(MSBuildExtensionsLayoutDirectory)' ^
|
||||||
'$(FullNugetVersion)'
|
'$(FullNugetVersion)' ^
|
||||||
'$(SdkMSBuildExtensionsNuspecFile)'
|
'$(SdkMSBuildExtensionsNuspecFile)' ^
|
||||||
'$(SdkMSBuildExtensionsNupkgFile)'" />
|
'$(SdkMSBuildExtensionsNupkgFile)'" />
|
||||||
|
|
||||||
<GenerateMSBuildExtensionsSWR MSBuildExtensionsLayoutDirectory="$(MSBuildExtensionsLayoutDirectory)"
|
<GenerateMSBuildExtensionsSWR MSBuildExtensionsLayoutDirectory="$(MSBuildExtensionsLayoutDirectory)"
|
||||||
|
@ -202,9 +202,9 @@
|
||||||
DependsOnTargets="Init;MsiTargetsSetupInputOutputs;GenerateSdkMsi"
|
DependsOnTargets="Init;MsiTargetsSetupInputOutputs;GenerateSdkMsi"
|
||||||
Condition=" '$(OS)' == 'Windows_NT'" >
|
Condition=" '$(OS)' == 'Windows_NT'" >
|
||||||
|
|
||||||
<Exec Command ="powershell -NoProfile -NoLogo $(SdkTestMsiPowershellScript)
|
<Exec Command ="powershell -NoProfile -NoLogo $(SdkTestMsiPowershellScript) ^
|
||||||
-InputMsi '$(SdkInstallerFile)'
|
-InputMsi '$(SdkInstallerFile)' ^
|
||||||
-DotnetDir '$(PreviousStageDirectory)'
|
-DotnetDir '$(PreviousStageDirectory)' ^
|
||||||
-TestDir '$(TestOutputDir)'" />
|
-TestDir '$(TestOutputDir)'" />
|
||||||
|
|
||||||
<WriteLinesToFile
|
<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]
|
[Theory]
|
||||||
[ClassData(typeof(SupportedNetCoreAppVersions))]
|
[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")
|
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
|
// scope the feed to only dotnet-core feed to avoid flaky when different feed has a newer / lower version
|
||||||
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
|
.WithNuGetConfig(new RepoDirectoriesProvider().TestPackages)
|
||||||
.WithSourceFiles();
|
.WithSourceFiles();
|
||||||
|
@ -37,6 +56,13 @@ namespace EndToEnd
|
||||||
.Element(ns + "TargetFramework")
|
.Element(ns + "TargetFramework")
|
||||||
.Value = "netcoreapp" + minorVersion;
|
.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);
|
project.Save(projectPath);
|
||||||
|
|
||||||
// Get the resolved version of .NET Core
|
// Get the resolved version of .NET Core
|
||||||
|
@ -48,7 +74,7 @@ namespace EndToEnd
|
||||||
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
||||||
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||||
|
|
||||||
var versionInAssertsJson = GetNetCoreAppVersion(assetsFile);
|
var versionInAssertsJson = GetPackageVersion(assetsFile, packageName);
|
||||||
versionInAssertsJson.Should().NotBeNull();
|
versionInAssertsJson.Should().NotBeNull();
|
||||||
|
|
||||||
if (versionInAssertsJson.IsPrerelease && versionInAssertsJson.Patch == 0)
|
if (versionInAssertsJson.IsPrerelease && versionInAssertsJson.Patch == 0)
|
||||||
|
@ -59,18 +85,18 @@ namespace EndToEnd
|
||||||
return;
|
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)
|
return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier == null)
|
||||||
?.Libraries?.SingleOrDefault(l =>
|
?.Libraries?.SingleOrDefault(l =>
|
||||||
string.Compare(l.Name, "Microsoft.NETCore.App", StringComparison.CurrentCultureIgnoreCase) == 0)
|
string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||||
?.Version;
|
?.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetExpectedVersion(string minorVersion)
|
public string GetExpectedVersion(string packageName, string minorVersion)
|
||||||
{
|
{
|
||||||
if (minorVersion.StartsWith("1.0"))
|
if (minorVersion.StartsWith("1.0"))
|
||||||
{
|
{
|
||||||
|
@ -82,6 +108,16 @@ namespace EndToEnd
|
||||||
}
|
}
|
||||||
else
|
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);
|
var parsed = NuGetVersion.Parse(minorVersion);
|
||||||
return new NuGetVersion(parsed.Major, parsed.Minor, 0).ToNormalizedString();
|
return new NuGetVersion(parsed.Major, parsed.Minor, 0).ToNormalizedString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,23 +14,37 @@ 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]
|
[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 ItRollsForwardToTheLatestVersion(string minorVersion)
|
public void ItRollsForwardToTheLatestNetCoreVersion(string minorVersion)
|
||||||
{
|
{
|
||||||
// https://github.com/dotnet/cli/issues/9661
|
ItRollsForwardToTheLatestVersion(NETCorePackageName, minorVersion);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
[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")
|
var _testInstance = TestAssets.Get("TestAppSimple")
|
||||||
.CreateInstance(identifier: minorVersion)
|
.CreateInstance(identifier: packageName + "_" + minorVersion)
|
||||||
.WithSourceFiles();
|
.WithSourceFiles();
|
||||||
|
|
||||||
string projectDirectory = _testInstance.Root.FullName;
|
string projectDirectory = _testInstance.Root.FullName;
|
||||||
|
@ -51,6 +65,13 @@ namespace EndToEnd
|
||||||
project.Root.Element(ns + "PropertyGroup")
|
project.Root.Element(ns + "PropertyGroup")
|
||||||
.Add(new XElement(ns + "RuntimeIdentifier", rid));
|
.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);
|
project.Save(projectPath);
|
||||||
|
|
||||||
// Get the version rolled forward to
|
// Get the version rolled forward to
|
||||||
|
@ -62,7 +83,7 @@ namespace EndToEnd
|
||||||
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
string assetsFilePath = Path.Combine(projectDirectory, "obj", "project.assets.json");
|
||||||
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
var assetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||||
|
|
||||||
var rolledForwardVersion = GetNetCoreAppVersion(assetsFile);
|
var rolledForwardVersion = GetPackageVersion(assetsFile, packageName);
|
||||||
rolledForwardVersion.Should().NotBeNull();
|
rolledForwardVersion.Should().NotBeNull();
|
||||||
|
|
||||||
if (rolledForwardVersion.IsPrerelease)
|
if (rolledForwardVersion.IsPrerelease)
|
||||||
|
@ -74,10 +95,21 @@ namespace EndToEnd
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Float the RuntimeFrameworkVersion to get the latest version of the runtime available from feeds
|
|
||||||
Directory.Delete(Path.Combine(projectDirectory, "obj"), true);
|
Directory.Delete(Path.Combine(projectDirectory, "obj"), true);
|
||||||
project.Root.Element(ns + "PropertyGroup")
|
if (packageName == NETCorePackageName)
|
||||||
.Add(new XElement(ns + "RuntimeFrameworkVersion", $"{minorVersion}.*"));
|
{
|
||||||
|
// 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);
|
project.Save(projectPath);
|
||||||
|
|
||||||
new RestoreCommand()
|
new RestoreCommand()
|
||||||
|
@ -87,19 +119,19 @@ namespace EndToEnd
|
||||||
|
|
||||||
var floatedAssetsFile = new LockFileFormat().Read(assetsFilePath);
|
var floatedAssetsFile = new LockFileFormat().Read(assetsFilePath);
|
||||||
|
|
||||||
var floatedVersion = GetNetCoreAppVersion(floatedAssetsFile);
|
var floatedVersion = GetPackageVersion(floatedAssetsFile, packageName);
|
||||||
floatedVersion.Should().NotBeNull();
|
floatedVersion.Should().NotBeNull();
|
||||||
|
|
||||||
rolledForwardVersion.ToNormalizedString().Should().BeEquivalentTo(floatedVersion.ToNormalizedString(),
|
rolledForwardVersion.ToNormalizedString().Should().BeEquivalentTo(floatedVersion.ToNormalizedString(),
|
||||||
"the latest patch version properties in Microsoft.NETCoreSdk.BundledVersions.props need to be updated " +
|
$"the latest patch version for {packageName} {minorVersion} in Microsoft.NETCoreSdk.BundledVersions.props " +
|
||||||
"(see MSBuildExtensions.targets in this repo)");
|
"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)
|
return lockFile?.Targets?.SingleOrDefault(t => t.RuntimeIdentifier != null)
|
||||||
?.Libraries?.SingleOrDefault(l =>
|
?.Libraries?.SingleOrDefault(l =>
|
||||||
string.Compare(l.Name, "Microsoft.NETCore.App", StringComparison.CurrentCultureIgnoreCase) == 0)
|
string.Compare(l.Name, packageName, StringComparison.CurrentCultureIgnoreCase) == 0)
|
||||||
?.Version;
|
?.Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,11 +157,40 @@ namespace EndToEnd
|
||||||
.Element(ns + "TargetFramework")
|
.Element(ns + "TargetFramework")
|
||||||
.Value;
|
.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 " +
|
.Should().Contain(targetFramework, $"the {nameof(SupportedNetCoreAppVersions)}.{nameof(SupportedNetCoreAppVersions.Versions)} property should include the default version " +
|
||||||
"of .NET Core created by \"dotnet new\"");
|
"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 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();
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
||||||
public static IEnumerable<object[]> Versions
|
public static IEnumerable<string> Versions
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
@ -20,7 +20,23 @@ namespace EndToEnd
|
||||||
"2.0",
|
"2.0",
|
||||||
"2.1",
|
"2.1",
|
||||||
"2.2"
|
"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