I'm using C#, .NET CORE 3.1, Visual Studio 2019.
The source solution contains many projects which using jenkins for build by command:
dotnet publish -f netcoreapp3.1 -r win-x86 --self-contained false /p:AssemblyVersion=\"1.1.1.1\" /p:Version=\"1.1.1.1\" /p:FileVersion=\"1.1.1.1\" -c release MySolutionFile.sln -o sln_build/MyProductBuild/win_x86"
I have to say in past months it works great, until days ago, I pull down a build artifacts and run it, an error was thrown:
Unhandled exception. System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (0x80131040)
I looked the file Microsoft.Extensions.DependencyInjection.Abstractions.dll
in artifacts folder, the File Version
was showing 2.2.0.18315
, obvious this is a wrong version, the expecting one should be with version 5.0.0.0
.
Then I'm trying to locate which project referenced this wrong version:
I searched
*.csproj
and*.deps.json
for each projects under the solution, could not see any project referened the wrong version, all referenced to5.0.0.0
.Delete all
obj
andbin
folder under each projects, and then re-publish, still no luck.
Any suggestions?
[edit0]
- Multiple .NET CORE SDKs installed on this build machine:
.NET SDKs installed: 2.1.811 [C:\Program Files\dotnet\sdk] 2.2.105 [C:\Program Files\dotnet\sdk] 3.0.103 [C:\Program Files\dotnet\sdk] 3.1.100 [C:\Program Files\dotnet\sdk] 3.1.403 [C:\Program Files\dotnet\sdk] 5.0.201 [C:\Program Files\dotnet\sdk]
- the
packages
in my build machine is located at:
C:\Windows\System32\config\systemprofile.nuget\packages
I removed the folder: microsoft.extensions.dependencyinjection
and microsoft.extensions.dependencyinjection.abstractions
.
after a new build, can see the above folders were created again and filled with different version of this assembly, include version
2.2
and5.0
and others.after a new build, the
Microsoft.Extensions.DependencyInjection.Abstractions
in each project's bin folder is with correct version, that means only the solution output folder get the wrong version.