I'm using .NET Framework 4.7.2 and I'm having an issue with this . The NuGet package says there is no dependency on Microsoft.Extensions.DependencyInjection but my builds fail.
I used NuGet to install Microsoft.Extensions.DependencyInjection manually but that doesn't resolve the problem either, it still fails to build.
I tried this with a new Console C# application and only installing GitVersionTask via NuGet.
I'm trying out GitVersionTask.5.1.4-beta1.99 since it contains new functionality I need to use.
GitVersionTask.5.1.4-beta1.99\build\GitVersionTask.targets(10,9): error : FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
1>C:\Users\Albert\source\repos\GitVersionTaskTestApp\packages\GitVersionTask.5.1.4-beta1.99\build\GitVersionTask.targets(10,9): error : at GitVersion.MSBuildTask.GitVersionTasks.BuildServiceProvider(GitVersionTaskBase task)
1>C:\Users\Albert\source\repos\GitVersionTaskTestApp\packages\GitVersionTask.5.1.4-beta1.99\build\GitVersionTask.targets(10,9): error : at GitVersion.MSBuildTask.GitVersionTasks.ExecuteGitVersionTask[T](T task, Action`1 action) in D:\a\1\s\src\GitVersionTask\GitVersionTasks.cs:line 25
I am also hit by this bug. If I see this right there is some kind of assembly redirection missing. We are looking for version 3.0.1 of Microsoft.Extensions.DependencyInjection.Abstractions.dll but have version 3.1.1 in packages\GitVersionTask\tools\net472.
Manifest of
.assembly Microsoft.Extensions.DependencyInjection.Abstractions
{
.ver 3:1:1:0
}
Assembly Loader log:
* Assembly Binder Log Entry (2/4/2020 @ 10:44:20 AM) *
The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable c:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe
--- A detailed error log follows.
Pre-bind state information
LOG: DisplayName = Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
(Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio/2017/Professional/MSBuild/15.0/Bin/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : Microsoft.Extensions.DependencyInjection, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60.
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Using application configuration file: C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\Bin\MSBuild.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
LOG: The same bind was seen before, and was failed with hr = 0x80070002.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80070002).
Are you able to fix the problem by adding assembly redirection to GitVersion?
I tried adding various app.configs inside the unpacked nuget package with the following inside:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
....<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" />
....<publisherPolicy apply="yes" />
....<bindingRedirect oldVersion="3.0.0.0-3.1.65535.65535" newVersion="3.1.1.0" />
</dependentAssembly>
</runtime>
</configuration>
GitVersionTask.dll.config
GitVersionTask.MsBuild.dll.config
GitVersionCore.dll.config
But it did not work. Not sure if I made a mistake.
I have also tried downloading the nuget of Microsoft.Extensions.DependencyInjection.Abstractions in version 3.0.1 and swapped the assembly 3.1.1 with 3.0.1. This did not work, too. But I am also not sure if this could work at all because the nuget only contains a netstandard2.0 folder and I am using net472 fir GitVersionTask. Sorry, this netstandard stuff is quite new to me.
@arturcic Thanks for working on this, but unfortunately new new pre-release 5.1.4-beta1.131 of GitVersionTask still has this issue. Just the error message changed slightly. Previously: Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.0.1.0 was not found, now Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.1.0.0 is not found. As before, the nuget package includes v3.1.1.0.
Anyway, from a fist glance Microsoft.Extensions.DependencyInjection seems the one to blame here. GitVersionTaks is compiled against v3.1.1, it ships v3.1.1 of both libraries (DI and DI.Abstrancions). But Microsoft.Extensions.DependencyInjection in version 3.1.1 is compiled against version 3.1.0 of Microsoft.Extensions.DependencyInjection.Abstractions.
Thanks for the input, it's weird as the artifact test that checks the msbuild artifact is passing...
There is an upstream issue for this; unfortunately it's not scheduled for their next 3.1.2 service release :-/
https://github.com/dotnet/extensions/issues/2931
Is there a way we could reproduce it ourselves? A little project with the repro would be handy, and we might add it as part of the artifacts validation
There is an upstream issue for this; unfortunately it's not scheduled for their next 3.1.2 service release :-/
dotnet/extensions#2931
I'll follow the issue, thanks for pointing to it
Is there a way we could reproduce it ourselves? A little project with the repro would be handy, and we might add it as part of the artifacts validation
Yes, I literally go File -> New Project, Create a C# Console project Targeting .NET Framework 4.7.2.
After that I install GitVersionTask. 5.1.4 Beta 136
Try to build, it fails.
1>C:\Users\Albert\source\repos\GitVersionNet472\packages\GitVersionTask.5.1.4-beta1.136\build\GitVersionTask.targets(10,9): error : FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The system cannot find the file specified.
1>C:\Users\Albert\source\repos\GitVersionNet472\packages\GitVersionTask.5.1.4-beta1.136\build\GitVersionTask.targets(10,9): error : at GitVersion.MSBuildTask.GitVersionTasks.BuildServiceProvider(GitVersionTaskBase task)
1>C:\Users\Albert\source\repos\GitVersionNet472\packages\GitVersionTask.5.1.4-beta1.136\build\GitVersionTask.targets(10,9): error : at GitVersion.MSBuildTask.GitVersionTasks.ExecuteGitVersionTask[T](T task, Action`1 action) in D:\a\1\s\src\GitVersionTask\GitVersionTasks.cs:line 25
1>C:\Users\Albert\source\repos\GitVersionNet472\packages\GitVersionTask.5.1.4-beta1.136\build\GitVersionTask.targets(10,9): error :
1>
1>Build FAILED.
If you want I can save a project, zip it up, and send your way, but it's a pretty basic and simple to reproduce. Let me know.
Cheers,