GitVersion: [BUG]: .NET 8.0 - MSB4062 The "WriteVersionInfoToBuildLog" task could not be loaded - reloaded
Prerequisites
- I have written a descriptive issue title
- I have searched issues to ensure it has not already been reported
GitVersion package
GitVersion.MsBuild
GitVersion version
6.0.0
Operating system
Windows
What are you seeing?
I’m seeing the error:
D:\packages\.nuget\gitversion.msbuild\6.0.0\tools\GitVersion.MsBuild.targets(25,9):
error MSB4062: The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly
D:\packages\.nuget\gitversion.msbuild\6.0.0\tools\net8.0\GitVersion.MsBuild.dll.
Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
or one of its dependencies.
The system cannot find the file specified.
Confirm that the <UsingTask> declaration...
#3787 and #3704 suggest that after the betas, version 6.0.0 should work with .NET 8.
After the above error is triggered, even reverting to 5.12.0 yields:
MSB4062 The "WriteVersionInfoToBuildLog" task could not be loaded from the assembly
D:\packages\.nuget\gitversion.msbuild\5.12.0\tools\net48/GitVersion.MsBuild.dll.
Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> .....
which weirdly tries to use net48, even though I’m not on the .NET Framework anywhere in my solution.
When the error is triggered, the only way to recover (remaining on 5.12.0) is to close and re-open solution (I’m not sure but it seems the error leaves a dotnet.exe process… )
What is expected?
Task works as with version 5.12.0
Steps to Reproduce
With:
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.10.4
**********************************************************************
dotnet msbuild -version
MSBuild version 17.10.4+10fbfbf2e for .NET
17.10.4.21802
dotnet --info
.NET SDK:
Version: 8.0.303
Commit: 29ab8e3268
Workload version: 8.0.300-manifests.34944930
MSBuild version: 17.10.4+10fbfbf2e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.303\
.NET workloads installed:
.... omitted ....
Host:
Version: 8.0.7
Architecture: x64
Commit: 2aade6beb0
.NET SDKs installed:
8.0.303 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
My csproj has:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<LangVersion>latest</LangVersion>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<WriteVersionInfoToBuildLog>true</WriteVersionInfoToBuildLog>
<UpdateAssemblyInfo>true</UpdateAssemblyInfo>
<GenerateGitVersionInformation>true</GenerateGitVersionInformation>
<GetVersion>true</GetVersion>
<GenerateGitVersionWixDefines>false</GenerateGitVersionWixDefines>
<UpdateVersionProperties>true</UpdateVersionProperties>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
RepositoryFixture Test
No response
Output log or link to your CI build (if appropriate).
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 5
- Comments: 36 (8 by maintainers)
Thanks @arturcic - Shame but I understand. Blocker for me as I’ve always seen the dotnet tool approach as a workaround and would rather see MSBuild do it. Also kills a project I was about to release GitVersion.Afterburner!! 😃
That clarifies it so i’ll do something else.
But … I do think it would be good to update both the breaking changes and also the site. Not supporting .NET 4.8 does not read as “Dropped VS support”. It will save a lot of angst making it clear.
Thanks 😃
I like the approach by @dorssel, and it actually seems to work well in one of my bigger solutions including Wix v5 installer projects.
Please don’t let this be closed automatically by a stale bot! Lot’s of .NET devs are stuck with Visual Studio, especially if they have to use WPF!
FYI, I created https://www.nuget.org/packages/Dorssel.GitVersion.MsBuild, which does support Visual Studio even with version 6 GitVersion tool.
This issue has been automatically marked as stale because it has not had recent activity. After 30 days from now, it will be closed if no further activity occurs.
Well actually I checked you repo and that helped with the response and the plan I mentioned above. So we need to deprecate those 2 tasks as they are duplicating what the dotnet tool does, which I guess for now we can embed (as we are testing the msbuild in docker images and the tools should be already available). And then we can just have the other 2 tasks consuming the json file and do the stuff. I think it’s better to have a different package like GitVersion.MsBuildv2 so that people can give it a try and see it works, that will eventually replace the current GitVersion.MsBuild
It’s not really a fork, just a lightweight re-implementation. From the closed “won’t fix” issues reported here my guess is that GitTools chose not to support anything except .NET CLI build; i.e., they are aware that VS no longer loads their MsBuild tasks and are fine with that.
Unrelated note:
I stumbled on this issue while debugging issues with my own custom build task that worked with Rider but not with Visual Studio.
The cause of the issue was that I followed the official instructions to create a nuget package but targeted
net8instead ofnetstandard2.0.When using
netstandard2.0, it just worked.I’m keen on this functionality being returned. It’s great to output the
SemVerin the footer and as a response header so the users know what version of the app they are using/testing. I get it’s for the build, which works well for NuGet packages and naming file downloads, but we’ve come to rely on GitVersion for this feature.