Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitVersion 6.0-beta.1 : Error on WriteVersionInfoToBuildLog with can't load System.Runtime 6.0.0.0 on a .NET 7 project #3450

Closed
ebfortin opened this issue Mar 25, 2023 · 12 comments
Labels
Milestone

Comments

@ebfortin
Copy link

I have an older solution with 4 projects in it. They were all .net 5 and using an older (5.x) version of GitVersion. I upgraded to 6.0 and also the framework to 7.0. After resolving the breaking changes from GitVersion from 5.x to 6.x I stumbled on an error that I have no idea how to resolve. I get the following for my 4 projects in my solution:

The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly C:\Users\efort.nuget\packages\gitversion.msbuild\6.0.0-beta.1\tools\net6.0/GitVersion.MsBuild.dll. Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

Would appreciate some help. If I should not post this kind of thing here please let me know. But since it's a Beta release it may be a bug or regression to fix so here I am :)

@ebfortin
Copy link
Author

ebfortin commented Mar 26, 2023

Additional information : I have .net 8 preview installed. But my projects are all .net 7 release.

@arturcic
Copy link
Member

arturcic commented Apr 1, 2023

Can you send us a sample project that can reproduce this issue? We have some integration tests for .net6.0 and .net7.0 that executes the build having this package installed as part of our pipeline, and it seems to be working fine

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

I created a bare minimum console app from Visual Studio's template. Can't be simpler than that.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net7.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="GitVersion.MsBuild" Version="6.0.0-beta.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

</Project>

I get the infamous Visual Studio yellow triangle of Death :

image

And the same error as before :

image

And finally my Program.cs code :

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

I also purged .NET 8 preview from my system. .NET version used by the .NET CLI and Visual Studio is .NET 7.0.202 (7.0.4).

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

Changing the target framework (5, 6, 7) doesn't make any difference. Error still present.

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

Building with the CLI works fine.

ETA : "dotnet build" works, msbuild (CLI) doesn't.

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

*** Assembly Binder Log Entry (2023-04-02 @ 1:35:52 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\MSBuild.exe
A detailed error log follows.

=== Pre-bind state information ===
LOG: DisplayName = System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
(Fully-specified)
LOG: Appbase = file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/amd64/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = MSBuild.exe
Calling assembly : GitVersion.MsBuild, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null.

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\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\MSBuild.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/amd64/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/amd64/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/amd64/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Program Files/Microsoft Visual Studio/2022/Preview/MSBuild/Current/Bin/amd64/System.Runtime/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Users/efort/.nuget/packages/gitversion.msbuild/6.0.0-beta.1/tools/net6.0/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/efort/.nuget/packages/gitversion.msbuild/6.0.0-beta.1/tools/net6.0/System.Runtime/System.Runtime.DLL.
LOG: Attempting download of new URL file:///C:/Users/efort/.nuget/packages/gitversion.msbuild/6.0.0-beta.1/tools/net6.0/System.Runtime.EXE.
LOG: Attempting download of new URL file:///C:/Users/efort/.nuget/packages/gitversion.msbuild/6.0.0-beta.1/tools/net6.0/System.Runtime/System.Runtime.EXE.
LOG: All probing URLs attempted and failed.

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

Sooooooooooooo

Tried a workaround. I added "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\6.0.15\System.Runtime.dll" to the Global Assembly Cache (GAC). It worked! Sort of... Now I get the same error but for System.Private.CoreLib.dll. Problem is I can't add that dll to the GAC. Gacutil refuse.

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

Ok last attempt. Copied System.Runtime.dll and System.Private.CoreLib.dll to gitversion.msbuild tools directory. Now I get the error "can't load type System.Object from System.Private.CoreLib because the parent does not exist".

@ebfortin
Copy link
Author

ebfortin commented Apr 2, 2023

Dependencies for GitVersion.MsBuild.dll 5.12.0 :

image

Dependencies for GitVersuib.MsBuild.dll 6.0.0-beta.1 :

image

Seems like missing dependencies. And these dependencies are visible when using "dotnet build" but not Visual Studio or msbuild.exe through Visual Studio.

@arturcic
Copy link
Member

@ebfortin it was fixed with commit c7f6267 #3474

It should be available in next release

@arturcic arturcic added this to the 6.x milestone Apr 13, 2023
@arturcic
Copy link
Member

Closed by #3474

@arturcic arturcic added the bug label Apr 14, 2023
@arturcic arturcic modified the milestones: 6.x, 6.0.0-beta.3 Jun 26, 2023
@arturcic
Copy link
Member

🎉 This issue has been resolved in version 6.0.0-beta.3 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants