Skip to content

Commit fe20f92

Browse files
Nate McMasternatemcmaster
authored andcommitted
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.
1 parent e751db0 commit fe20f92

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

build/dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@
9898
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
9999
<CastleCorePackageVersion>4.2.1</CastleCorePackageVersion>
100100
<DevDependency_MicrosoftDotNetBuildTasksFeedPackageVersion>2.1.0-prerelease-02430-04</DevDependency_MicrosoftDotNetBuildTasksFeedPackageVersion>
101-
<DevDependency_MicrosoftExtensionsDependencyModelPackageVersion>2.0.0</DevDependency_MicrosoftExtensionsDependencyModelPackageVersion>
101+
<DevDependency_MicrosoftExtensionsDependencyModelPackageVersion>2.1.0</DevDependency_MicrosoftExtensionsDependencyModelPackageVersion>
102102
<DevDependency_WindowsAzureStoragePackageVersion>8.7.0</DevDependency_WindowsAzureStoragePackageVersion>
103103
<FSharpCorePackageVersion>4.2.1</FSharpCorePackageVersion>
104104
<GoogleProtobufPackageVersion>3.1.0</GoogleProtobufPackageVersion>

test/SharedFx.UnitTests/SharedFxTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,28 @@ public void ItContainsValidDepsJson(SharedFxConfig config)
4747
Assert.NotNull(depsFile["compilationOptions"]);
4848
Assert.Empty(depsFile["compilationOptions"]);
4949
Assert.NotEmpty(depsFile["runtimes"][config.RuntimeIdentifier]);
50+
51+
var targetLibraries = depsFile["targets"][target];
52+
Assert.All(targetLibraries, libEntry =>
53+
{
54+
var lib = Assert.IsType<JProperty>(libEntry);
55+
if (lib.Value["runtime"] == null)
56+
{
57+
return;
58+
}
59+
60+
Assert.All(lib.Value["runtime"], item =>
61+
{
62+
var obj = Assert.IsType<JProperty>(item);
63+
var assemblyVersion = obj.Value["assemblyVersion"];
64+
Assert.NotNull(assemblyVersion);
65+
Assert.NotEmpty(assemblyVersion.Value<string>());
66+
67+
var fileVersion = obj.Value["fileVersion"];
68+
Assert.NotNull(fileVersion);
69+
Assert.NotEmpty(fileVersion.Value<string>());
70+
});
71+
});
5072
}
5173

5274
[Theory]

0 commit comments

Comments
 (0)