From fe20f9240d30264e4e27c0838690f64985a5a846 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 11 Jan 2019 11:47:33 -0800 Subject: [PATCH] Fix #3503 - update buildtools dependency on DependencyModel to 2.1.0 The 2.0 version of the Microsoft.Extensions.DependencyModel does not support the assembly/file version metadata. We must have at least 2.1. Between 2.1.6 and 2.1.7, we switched the build to use MSBuild.exe ("full" MSBuild) instead of `dotnet msbuild` ("core" MSBuild). MSBuild has different assembly loaders behaviors in core vs full. By switching MSBuild types, we were also unintentionally switching the version of Microsoft.Extensions.DependencyModel.dll that was being used by our build task from 2.1 back down to 2.0. The reason we didn't discover this in earlier 2.1.x patches is that building on msbuild core automatically upgraded our build tasks to Microsoft.Extensions.DependencyModel.dll, Version=2.1.0.0. This happens because of differences in the way .NET Core and MSBuild handles assemblies with the same ID and different versions, and differences in the layout of MSBuild and the .NET Core CLI. In the end, this happened because we didn't have test coverage. MSBuild and custom tasks burned asagain, but we should have just had unit tests all along, which would have uncovered this regression as soon as we switched to msbuild.exe. --- build/dependencies.props | 2 +- test/SharedFx.UnitTests/SharedFxTests.cs | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/build/dependencies.props b/build/dependencies.props index d6e1e63e78..e3872095db 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -98,7 +98,7 @@ 0.10.13 4.2.1 2.1.0-prerelease-02430-04 - 2.0.0 + 2.1.0 8.7.0 4.2.1 3.1.0 diff --git a/test/SharedFx.UnitTests/SharedFxTests.cs b/test/SharedFx.UnitTests/SharedFxTests.cs index d18fa17ef8..36160360df 100644 --- a/test/SharedFx.UnitTests/SharedFxTests.cs +++ b/test/SharedFx.UnitTests/SharedFxTests.cs @@ -47,6 +47,28 @@ namespace Microsoft.AspNetCore Assert.NotNull(depsFile["compilationOptions"]); Assert.Empty(depsFile["compilationOptions"]); Assert.NotEmpty(depsFile["runtimes"][config.RuntimeIdentifier]); + + var targetLibraries = depsFile["targets"][target]; + Assert.All(targetLibraries, libEntry => + { + var lib = Assert.IsType(libEntry); + if (lib.Value["runtime"] == null) + { + return; + } + + Assert.All(lib.Value["runtime"], item => + { + var obj = Assert.IsType(item); + var assemblyVersion = obj.Value["assemblyVersion"]; + Assert.NotNull(assemblyVersion); + Assert.NotEmpty(assemblyVersion.Value()); + + var fileVersion = obj.Value["fileVersion"]; + Assert.NotNull(fileVersion); + Assert.NotEmpty(fileVersion.Value()); + }); + }); } [Theory]