Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Custom.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

<PropertyGroup>
<RuntimeFrameworkVersion>10.0.15</RuntimeFrameworkVersion>
<RollForward>Disable</RollForward>
<RollForward Condition="'$(CI)' != ''">Disable</RollForward>
</PropertyGroup>

<PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
namespace Tests
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using Microsoft.AspNetCore.Http;
using NUnit.Framework;
Expand Down Expand Up @@ -48,6 +50,7 @@ public void DuplicateAssembliesInDeploymentUnitsShouldHaveMatchingVersions()
Assert.That(detectedMismatches, Is.Empty, $"Component assembly version mismatch detected");
}

// This test will fail if you are not using the exact runtime version specified in the RuntimeFrameworkVersion property in the Custom.Build.props file
[Test]
public void DuplicateAssembliesFromRuntimeShouldHaveMatchingVersions()
{
Expand All @@ -61,9 +64,18 @@ public void DuplicateAssembliesFromRuntimeShouldHaveMatchingVersions()
detectedMismatches.AddRange(GetAssemblyMismatches(deploymentUnit, runtimeDeploymentUnit));
}

Assert.That(detectedMismatches, Is.Empty, $"Component assembly version mismatch detected");
var expectedVersion = typeof(DeploymentPackageTests).Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>()
.Single(a => a.Key == "RuntimeFrameworkVersion").Value;

var runtimeMessage = Environment.Version > Version.Parse(expectedVersion)
? $" Runtime rolled forward from requested {expectedVersion} to {Environment.Version}. This test requires the exact runtime version specified in Custom.Build.props."
: $" Requested runtime: {expectedVersion}; running runtime: {Environment.Version}.";

Assert.That(detectedMismatches, Is.Empty, $"Component assembly version mismatch detected.{runtimeMessage}");
}

// This test will fail if you are not using the exact runtime version specified in the RuntimeFrameworkVersion property in the Custom.Build.props file
[Test]
public void DuplicateAssembliesFromASPNetCoreShouldHaveMatchingVersions()
{
Expand All @@ -77,7 +89,15 @@ public void DuplicateAssembliesFromASPNetCoreShouldHaveMatchingVersions()
detectedMismatches.AddRange(GetAssemblyMismatches(deploymentUnit, aspNetCoreDeploymentUnit));
}

Assert.That(detectedMismatches, Is.Empty, $"Component assembly version mismatch detected");
var expectedVersion = typeof(DeploymentPackageTests).Assembly
.GetCustomAttributes<AssemblyMetadataAttribute>()
.Single(a => a.Key == "RuntimeFrameworkVersion").Value;

var runtimeMessage = Version.Parse(aspNetCoreDirectory.Name) > Version.Parse(expectedVersion)
? $" ASP.NET Core runtime rolled forward from requested {expectedVersion} to {aspNetCoreDirectory.Name}. This test requires the exact runtime version specified in Custom.Build.props."
: $" Requested ASP.NET Core runtime: {expectedVersion}; running runtime: {aspNetCoreDirectory.Name}.";

Assert.That(detectedMismatches, Is.Empty, $"Component assembly version mismatch detected.{runtimeMessage}");
}

IEnumerable<string> GetAssemblyMismatches(DeploymentPackage.DeploymentUnit leftDeploymentUnit, DeploymentPackage.DeploymentUnit rightDeploymentUnit)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@
<PackageReference Include="NUnit3TestAdapter" />
</ItemGroup>

<ItemGroup>
<AssemblyMetadata Include="RuntimeFrameworkVersion" Value="$(RuntimeFrameworkVersion)" />
</ItemGroup>

</Project>
Loading