dotnet-installer/test/EndToEnd/GivenUsingDefaultRuntimeFrameworkVersions.cs

89 lines
4.3 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using FluentAssertions;
using Microsoft.DotNet.Tools.Test.Utilities;
using NuGet.Versioning;
using Xunit;
namespace EndToEnd
{
public partial class GivenUsingDefaultRuntimeFrameworkVersions : TestBase
{
private static readonly IEnumerable<string> frameworks = new string[] {"Microsoft.NETCore.App", "Microsoft.WindowsDesktop.App",
"Microsoft.WindowsDesktop.App.WPF", "Microsoft.WindowsDesktop.App.WindowsForms", "Microsoft.AspNetCore.App" };
private static readonly IEnumerable<string> versions = SupportedNetCoreAppVersions.Versions.Where(version => NuGetVersion.Parse(version).Major >= 3);
[Fact]
public void DefaultRuntimeVersionsAreUpToDate()
{
var outputFile = "resolvedVersions.txt";
var testProjectCreator = new TestProjectCreator()
{
PackageName = "DefaultRuntimeVersionsAreUpToDate",
MinorVersion = "3.0"
};
var testProject = testProjectCreator.Create();
var projectFile = new DirectoryInfo(testProject.Root.FullName).GetFiles("*.csproj").First().FullName;
var project = XDocument.Load(projectFile);
string writeResolvedVersionsTarget = @$"
<Target Name=`WriteResolvedVersions` AfterTargets=`PrepareForBuild;ProcessFrameworkReferences`>
<ItemGroup>
<LinesToWrite Include=`%(KnownFrameworkReference.Identity) %(KnownFrameworkReference.DefaultRuntimeFrameworkVersion) %(KnownFrameworkReference.LatestRuntimeFrameworkVersion)`/>
</ItemGroup>
<WriteLinesToFile File=`$(OutputPath){ outputFile }`
Lines=`@(LinesToWrite)`
Overwrite=`true`
Encoding=`Unicode`/>
</Target>";
writeResolvedVersionsTarget = writeResolvedVersionsTarget.Replace('`', '"');
var targetElement = XElement.Parse(writeResolvedVersionsTarget);
var ns = project.Root.Name.Namespace;
foreach (var elem in targetElement.Descendants())
elem.Name = ns + elem.Name.LocalName;
targetElement.Name = ns + targetElement.Name.LocalName;
project.Root.Add(targetElement);
using (var file = File.CreateText(projectFile))
{
project.Save(file);
}
new RestoreCommand()
.WithWorkingDirectory(testProject.Root.FullName)
.Execute()
.Should().Pass();
var binDirectory = new DirectoryInfo(testProject.Root.FullName).Sub("bin").Sub("Debug").GetDirectories().FirstOrDefault();
binDirectory.Should().HaveFilesMatching(outputFile, SearchOption.TopDirectoryOnly);
var resolvedVersionsFile = File.ReadAllLines(Path.Combine(binDirectory.FullName, outputFile));
foreach (var framework in frameworks)
{
foreach (var version in versions)
{
var frameworkVersionLine = resolvedVersionsFile.Where(line => line.Contains(framework) && line.Contains(version)).FirstOrDefault();
[master] Update dependencies from dotnet/sdk (#8235) [master] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.NETCore.App.Ref: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Internal: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.TargetingPack.x64.5.0: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - dotnet-watch: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 5.0.0-rc.1.20419.1 to 6.0.0-alpha.1.20454.5 (parent: Microsoft.NET.Sdk) - Updates: - Microsoft.DotNet.MSBuildSdkResolver: from 5.0.100-rc.1.20420.8 to 6.0.100-alpha.1.20454.15 - Microsoft.NET.Sdk: from 5.0.100-rc.1.20420.8 to 6.0.100-alpha.1.20454.15 - Microsoft.NETCore.App.Ref: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.App.Internal: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.App.Runtime.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.App.Host.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.DotNetHostResolver: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.Platforms: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.AspNetCore.App.Ref: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - Microsoft.AspNetCore.App.Runtime.win-x64: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - VS.Redist.Common.AspNetCore.TargetingPack.x64.5.0: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - dotnet-dev-certs: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - dotnet-user-secrets: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - dotnet-watch: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - Microsoft.DotNet.Common.ItemTemplates: from 5.0.0-rc.1.20419.1 to 6.0.0-alpha.1.20454.5 - Update NuGet.config - Updates for 6.0 runtime - Reenabling test - Fixup toolset base url
2020-09-04 22:28:24 +00:00
if (!string.IsNullOrEmpty(frameworkVersionLine))
{
[master] Update dependencies from dotnet/sdk (#8235) [master] Update dependencies from dotnet/sdk - Coherency Updates: - Microsoft.NETCore.App.Ref: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Internal: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Runtime.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.App.Host.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.DotNetHostResolver: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.NETCore.Platforms: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Ref: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - Microsoft.AspNetCore.App.Runtime.win-x64: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - VS.Redist.Common.AspNetCore.TargetingPack.x64.5.0: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - dotnet-dev-certs: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - dotnet-user-secrets: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - dotnet-watch: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 (parent: Microsoft.NET.Sdk) - Microsoft.DotNet.Common.ItemTemplates: from 5.0.0-rc.1.20419.1 to 6.0.0-alpha.1.20454.5 (parent: Microsoft.NET.Sdk) - Updates: - Microsoft.DotNet.MSBuildSdkResolver: from 5.0.100-rc.1.20420.8 to 6.0.100-alpha.1.20454.15 - Microsoft.NET.Sdk: from 5.0.100-rc.1.20420.8 to 6.0.100-alpha.1.20454.15 - Microsoft.NETCore.App.Ref: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.App.Internal: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.App.Runtime.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.App.Host.win-x64: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.DotNetHostResolver: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.NETCore.Platforms: from 5.0.0-rc.1.20417.14 to 6.0.0-alpha.1.20453.28 - Microsoft.AspNetCore.App.Ref: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - Microsoft.AspNetCore.App.Runtime.win-x64: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - VS.Redist.Common.AspNetCore.TargetingPack.x64.5.0: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - dotnet-dev-certs: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - dotnet-user-secrets: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - dotnet-watch: from 5.0.0-rc.1.20419.22 to 5.0.0-rc.2.20454.3 - Microsoft.DotNet.Common.ItemTemplates: from 5.0.0-rc.1.20419.1 to 6.0.0-alpha.1.20454.5 - Update NuGet.config - Updates for 6.0 runtime - Reenabling test - Fixup toolset base url
2020-09-04 22:28:24 +00:00
var defaultVersion = NuGetVersion.Parse(frameworkVersionLine.Split(" ")[1]);
var latestVersion = NuGetVersion.Parse(frameworkVersionLine.Split(" ")[2]);
if (latestVersion.Patch == 0 && latestVersion.IsPrerelease)
{
defaultVersion.Should().Be(latestVersion,
$"the DefaultRuntimeFrameworkVersion for { framework } { version } in Microsoft.NETCoreSdk.BundledVersions.props does not match latest prerelease version { latestVersion }");
}
else
{
defaultVersion.Should().Be(new NuGetVersion(latestVersion.Major, latestVersion.Minor, 0),
$"the DefaultRuntimeFrameworkVersion for { framework } { version } in Microsoft.NETCoreSdk.BundledVersions.props needs to be updated to { version }.0");
}
}
}
}
}
}
}