I have a Visual Studio ASP.NET Core Web API project that in local dev environment restores, builds, and runs with no problem.
I have a TeamCity pipeline with the following steps :
.NET CLI Restore
.NET CLI Build
.NET CLI Publish
The pipeline runs with no errors.
The published set of binaries is deployed to IIS.
Application startup throws exception :
FileLoadException: Could not load file or assembly 'Microsoft.Extensions.WebEncoders, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I can resolve this issue by adding an explicit package reference to the .csproj :
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
However, next I will receive a different exception :
FileLoadException: Could not load file or assembly 'Microsoft.AspNetCore.StaticFiles, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
And so on as it works its way through the dependencies tree.
Clearly it's not realistic to repeat this process until all dependencies are explicitly specified with package references.
When run on the TeamCity Build Agent , MSBuild Publish is selecting assembly version different than the version required at runtime.
User contributions licensed under CC BY-SA 3.0