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

[BUG]: .NET 8.0 - MSB4062 The "WriteVersionInfoToBuildLog" task could not be loaded - reloaded #4116

Open
2 tasks done
sanghel-orbyta opened this issue Jul 24, 2024 · 34 comments

Comments

@sanghel-orbyta
Copy link

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

@Szaamaan
Copy link

Szaamaan commented Jul 29, 2024

I'm guessing you're using VS due to the Visual Studio 2022 Developer Command Prompt v17.10.4 header visible in one of your logs?

Apparently the GitVersion team dropped support for Visual Studio entirely, regardless of the target framework being used. 😕 Or at least that's the way I understand the replies...

@sanghel-orbyta
Copy link
Author

@Szaamaan , you're seeing that header because that's the CLI I've used to output local versions of msbuild, sdk, ecc..

But yes, I'm using VS2022., but I'm not trying to use GitVersion with anything .NET Framework related, I'm all on .NET 8.

@Szaamaan
Copy link

Szaamaan commented Jul 29, 2024

@Szaamaan , you're seeing that header because that's the CLI I've used to output local versions of msbuild, sdk, ecc..

But yes, I'm using VS2022., but I'm not trying to use GitVersion with anything .NET Framework related, I'm all on .NET 8.

Yes, I know. But despite this, apparently, something doesn't work quite the same way with Visual Studio's msbuild vs the one that's used by dotnet. The end result is that you can have the simplest "hello world" console app targeting the latest NET 8.0 and it just won't compile under Visual Studio if you add GitVersion.MsBuild and reference GitVersionInformation.

On that note - do you get the same results if you run dotnet build outside of the VS Command line (i.e. run it from a regular Powershell / CMD)?

@sanghel-orbyta
Copy link
Author

sanghel-orbyta commented Jul 29, 2024

I've just tried building with 6.0.0 via dotnet build from project folder.
...build fails with 3 occurrences of

error CS0579: Duplicate 'System.Reflection.AssemblyFileVersionAttribute' attribute

image
image

Reverting to 5.12.0 builds correctly (with both VS and from terminal dotnet build)...

Maybe it's me, but 6.0.0 doesn't seem "RTM"-ready....
Without the MSBuild version working correctly, there is no version retrieval at runtime as illustrated in the Accessing injected Variables section here.

I'm staying on 5.12.0, hoping that these issues might be fixed...

@M0n7y5
Copy link

M0n7y5 commented Aug 8, 2024

I have the same issue. MSBuild task won't generate static GitVersionInformation class. I can't compile any of my projects after upgrading from 5.12.0 to 6.x.x.

@ashleyjlive
Copy link

ashleyjlive commented Aug 12, 2024

Same issue here. 6.0.0 and 6.0.1 are both faulty.

@sanghel-orbyta
Copy link
Author

@ashleyjlive any chance you could retry it with 6.0.2, just to keep this issue relevant?

@AnrovaJens
Copy link

@sanghel-orbyta I've got the same issue with VS 2022 and .NET 8.0 and version 6.0.2 didn't resolve this for me.

@arturcic
Copy link
Member

@ashleyjlive any chance you could retry it with 6.0.2, just to keep this issue relevant?

If an issue is closed and there is a comment similar to #4157 (comment), only in that case the issue is considered fixed, or if we explicitly mention. At this moment VS is not supported because of the reasons mentioned #4130. Hopefully we will have the time to find a solution, but at this point if you need to use the MsBuild package together with Visual Studio I would recommend to stick to version 5.12.0 for now

@M0n7y5
Copy link

M0n7y5 commented Aug 14, 2024

@ashleyjlive any chance you could retry it with 6.0.2, just to keep this issue relevant?

Tested with 6.0.2 -> Still an issue. I have the same error but for GenerateGitVersionInformation

My error is:

GitVersion.MsBuild.targets(105,9): error MSB4062: The "GenerateGitVersionInformation" task could not be loaded from the assembly 
C:\Users\REDACTED\.nuget\packages\gitversion.msbuild\6.0.2\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 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.

Many things inside GitVersion.MsBuild.targets are undefined for some reason:
image

@RobSmyth
Copy link

@ashleyjlive - I was able to work around that by adding to the csproj:

<WriteVersionInfoToBuildLog>false</WriteVersionInfoToBuildLog>

I have it (I think) working a project but not another. See also: #4130

@RobSmyth
Copy link

Wow ... I misunderstood the "not supported" as "we do not have the time". But alas it has actually explicitly been removed (my bad). This is from the props file:

   <!-- The GitVersion task is explicitly disabled when running on the .NET Framework because it's no longer supported. 
   If a project that uses GitVersion.MsBuild is opened in Visual Studio, 
   the task will be turned off because Visual Studio operates on the .NET Framework's version of MSBuild. 
   However, you can still execute GitVersion.MsBuild as part of the `dotnet build` or `dotnet msbuild` commands. -->
   <DisableGitVersionTask Condition=" '$(MSBuildRuntimeType)' != 'Core' ">true</DisableGitVersionTask>

I now see it in the breaking changes (good). Missed it before. :-(

@arturcic - Perhaps the GitVersion site (https://gitversion.net/docs/usage/msbuild) should mention GitVersion.MSBuild's Visual Studio retirement . Could save a lot of time.

I think there is a big difference between a bug that may take a while to fix and a retirement of support for Visual Studio.

Is there any point looking into it if the team does not plan to support VS?

@RobSmyth
Copy link

BTW - .NET Framework support is not actually required to work in VS. As a minimum it needs to support .NET Standard 2.0 and that was removed in 6.0.0.

@RobSmyth
Copy link

@arturcic - had a bit more of a look and I think the .NET Standard 2.0 support, and hence Visual Studio support, was dropped in a commit Jan 9, 2023 (merged Feb 18, 2023). There is another possibly related commit Nov 6, 2023. I think, these are your commits. Can you tell me if loss of VS support was a side affect here or intentional?

It looks like it may be a clean-up moving stuff to the root folder.

Commits:

Thanks

@arturcic
Copy link
Member

@RobSmyth the idea was we wanted to start using the new APIs in the newer versions of .NET and targeting netstandard put too much maintenance on us. Same for the .net framework. Then we saw it was broken in VS and we had to decide to either spend time on building new features, take advantage of new APIs, or be stuck on netstandard.

At this point netstandard was needed mainly for GitVersion.MsBuild package which is not the most used package we publish, it's like 5% of the usage and was like 60% or so of the effort.

That still does not mean we will not get back to this issue at some point, but that will take time, and it will require a different approach

@RobSmyth
Copy link

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 :-)

@tammha
Copy link

tammha commented Aug 28, 2024

Hi everyone, I have just come across GitVersion as we are planning to use this with our company projects.
I downloaded 6.0.2 and all seems working fine via dotnet build. However if I set UseProjectNamespaceForGitVersionInformation to true in my directory.build.props, dotnet build will result in

obj\Debug\Debug\net8.0\GitVersionInformation.g.cs(28,1): error CS1022: Type or namespace definition, or end-of-file expected

The file GitVersionInformation.g.cs seems to only get generated if you set UseProjectNamespaceForGitVersionInformation to true. Inside GitVersionInformation.g.cs , I think GitVersion is trying to inject the "RootNameSpace" or if not, it will inject the project name.

The compile/build error I traced back to a potential bug in the class:

internal sealed class GitVersionInfoGenerator(IFileSystem fileSystem) : IGitVersionInfoGenerator

in Modules.GitVersion.Output.GitVersionInfo

The line of code that seems to be causing the issue is commented below:

string getTargetNamespace(string extension) => extension switch
{
".vb" => context.TargetNamespace ?? "Global",
// ".cs" => context.TargetNamespace != null ? $"{PathHelper.NewLine}namespace {context.TargetNamespace};" : "",
".cs" => context.TargetNamespace != null ? $"{PathHelper.NewLine}namespace {context.TargetNamespace}" : "",
".fs" => context.TargetNamespace ?? "global",
_ => targetNamespaceSentinelValue,
};

there seems to be an extra semi colon here: ....... namespace {context.TargetNamespace};" : ""

This I think caused the GitVersionInformation.g.cs to be created like :

namespace MyChosenRootNS;
{
{
[global::System.Runtime.CompilerServices.CompilerGenerated]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
static class GitVersionInformation
{........... the rest

If that extra semcolon is removed from that class, it should result in the namespace to be injected without ";". And donet build works fine in creating the GitVersionInformation.g.cs file

I am not really sure, but just a hunch, and hope this helped out.

Regards,
tam

@arturcic
Copy link
Member

@tammha if you want please submit a PR with the fix

@MrMTaylor
Copy link

I'm keen on this functionality being returned. It's great to output the SemVer in 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.

@paul-scharnofske-AP
Copy link

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 net8 instead of netstandard2.0.

When using netstandard2.0, it just worked.

@Cinter94
Copy link

@sanghel-orbyta with Rider no issues!!!

@dorssel
Copy link

dorssel commented Dec 2, 2024

FYI, I created https://www.nuget.org/packages/Dorssel.GitVersion.MsBuild, which does support Visual Studio even with version 6 GitVersion tool.

@RobSmyth
Copy link

RobSmyth commented Dec 2, 2024

FYI, I created https://www.nuget.org/packages/Dorssel.GitVersion.MsBuild, which does support Visual Studio even with version 6 GitVersion tool.

Very nice. That ought to help a lot of people who want to stay with GitVersion.

I went a different path with the version 6 release and created a different versioning framework entirely.

@arp-mbender
Copy link

I went a different path with the version 6 release and created a different versioning framework entirely.

May I curiously ask what you went with?

@namtab00
Copy link

namtab00 commented Dec 2, 2024

FYI, I created https://www.nuget.org/packages/Dorssel.GitVersion.MsBuild, which does support Visual Studio even with version 6 GitVersion tool.

Why the fork instead of contributing a PR ?

@arturcic
Copy link
Member

arturcic commented Dec 2, 2024

FYI, I created https://www.nuget.org/packages/Dorssel.GitVersion.MsBuild, which does support Visual Studio even with version 6 GitVersion tool.

Why the fork instead of contributing a PR ?

I don't mind having a fork, as long as the idea works and when it covers most of the current functionality we can re-integrate as long as the license permits. At least the ideas are welcomed

@dorssel
Copy link

dorssel commented Dec 3, 2024

FYI, I created https://www.nuget.org/packages/Dorssel.GitVersion.MsBuild, which does support Visual Studio even with version 6 GitVersion tool.

Why the fork instead of contributing a PR ?

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.

@arturcic
Copy link
Member

arturcic commented Dec 3, 2024

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.

I actually mentioned the reasons already before and also mentioned

Hopefully we will have the time to find a solution.

Which might be similar in approach with solution provided by @dorssel

@RobSmyth
Copy link

RobSmyth commented Dec 3, 2024

@arp-mbender ,

I went a different path with the version 6 release and created a different versioning framework entirely.

May I curiously ask what you went with?

I'm now using my own: Git2SemVer.MSBuild.

It uses a dotnet tool for setup and, in beta, to generate versioning info too: Git2SemVer.Tool.

Working well for me but it is early days. Under active development.

These do not try to replicate GitVersion but take a different approach. No commit depths (counts) :-)

@RobSmyth
Copy link

RobSmyth commented Dec 3, 2024

@arturcic ,

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.

I actually mentioned the reasons already before and also mentioned

Hopefully we will have the time to find a solution.

Which might be similar in approach with solution provided by @dorssel

You have tried to explain the reason and I'm sure they are self evident to the team. But, at least to me, the reasons given a vague.

What I remember hearing are:

  • The team wanted to use a new API (which API?)
  • Not having anybody to support Framework 4.71 (I read that as standard 2.0). Recently I've worked with .NET standard 2.0, .NET core 3.5, .NET 8.0, and .NET 4.7.1 so maybe it is just that I do not see the obvious.

If we take those reasons as given then:

  • Cannot ensure use of a new API that we do not know what it is
  • Support of Visual Studio MSBuild is out and no PR can be accepted. As it will use .NET standard 2.0.
  • Hard to provide solutions when the problems are vague.

However, if you could give details on the perceived problems like:

  • What APIs does the team want to use and for what?
  • What are the difficulties in supporting a .net standard 2.0 build?
  • Why was it removed?

Then others may be able to provide solutions, or start discussions, for resurrecting the very important VS support. I'm sure people want to help but just do not know how to.

I started to look to help but got stuck on "it was removed for a reason, how can I restore it without knowing the need and problem?"

@arturcic
Copy link
Member

arturcic commented Dec 3, 2024

However, if you could give details on the perceived problems like:

  • What APIs does the team want to use and for what?

A simpler way to understand which API/features we want to use, just add this line
<TargetFramework>netstandard2.0</TargetFramework> in GitVersion.Core.csproj, and all the errors will be hopefully self-explanatory, but in short it's about supporting the latest LTS version available of dotnet and it's corresponding C# version.

  • What are the difficulties in supporting a .net standard 2.0 build?
    The difficulty here is not the GitVersion.MsBuild per se as it has not that much code, as it relies on the GitVersion.Core, GitVersion.Output projects. The reason for having dependencies on these projects is we wanted to make GitVersion.App and GitVersion.MsBuild use the same codebase for running the versioning logic and the output handling which was not the case.
  • Why was it removed?
    Three reasons
  • we have a small team that wants to benefit from the changes the .NET team adds to the stack both in terms of performance an improved APIs as well as make it more appealing for potential contributors (nobody wants to spend their time on supporting an open source tool that uses legacy technologies),

  • we have a small team that has limited resources that wants to focus on improving the tool and not trying to solve compatibility issues introduced by multi-targeting the Core project (where at some point we had #ifdef conditions checking for 4 target frameworks - which adds up to the overhead for the team, I spent myself weeks on trying to make it work in the past),

  • we have several long waiting to be implemented features that needs our focus (some of them already 3 or more years) like:

    1. rework on the cli argument parsing (or new cli how we call it) as the current cli parsing is really old and outdated and which follows the old windows batch style
    2. replace LibGit2Sharp dependency with a Managed version if possible
    3. prepare for AOT
      There are more smaller features like adding back the init command that will help create the GitVersion configuration file taking in consideration the changes added in v6 to configuration system and so on, not to mention the regular chore we have to do.

As for the possible solution for the GitVersion.MsBuild package.

In the current implementation GitVersion.MsBuild uses the embedded GitVersion.Tool as 'dll's (see https://nuget.info/packages/GitVersion.MsBuild/6.0.5 tools/net8.0 for example) to execute and compute the version into a GitVersion.json file, that is later read into the GitVersion.MsBuild

private GitVersionVariables GitVersionVariables(GitVersionTaskBase task) => serializer.FromFile(task.VersionFile);
and used in each Task.

At this moment GitVersion.MsBuild supports these tasks:

  • GenerateGitVersionInformation - generates a class that is added to the compilation and allows to access the version variables in code
  • GetVersion - sets the version variables as msbuild properties
  • UpdateAssemblyInfo - updates the project's assembly info with version variables specific to AssemblyInfo
  • WriteVersionInfoToBuildLog - for the build agents that have support adds CI specific output messages that sets variables in the pipeline (GitHub Actions or Azure pipelines for example)

The last 2 tasks: UpdateAssemblyInfo and WriteVersionInfoToBuildLog are actually duplicating the functionality that GitVersion.Tool provides, and because GitVersion.MsBuild internally uses GitVersion.Tool, I think we just need to drop their implementation in GitVersion.MsBuild and just add the corresponding arguments on the tool.

The remaining 2 tasks should be kept in GitVersion.MsBuild as these are the only features it adds on top of GitVersion.Tool. By doing that we can reduce the dependency on GitVersion.Core and GitVersion.Output up to the point we can link the necessary files in the GitVersion.MsBuild instead of depending on other projects that target .net80. This will allow us to set the target for GitVersion.MsBuild to netstandard2.0

Hope these answer the questions and the vision for the GitVersion.MsBuild

@RobSmyth
Copy link

RobSmyth commented Dec 3, 2024

@arturcic ,

Thanks for taking the time to try and give more info, but it does not answer my questions. Sorry, probably I'm just thick.

Hope it works out for you as you have put a lot into it over a long period you have helped a LOT of people. The fundamental for me is that I do not need to install any other tools, no external scripts ... the project compiles and versions in VS and dotnet CLI the same. I hold it important that devs get versioning and devs compile the same as the build system does.

I think I'm just getting in your way. Thanks again for taking the time.

@dorssel
Copy link

dorssel commented Dec 4, 2024

@arturcic
Thanks for the elaborate reasoning. I don't want to fork, I just had to in order to prevent all kinds of workarounds for using Visual Studio. I have been using GitVersion for years, and will keep using it because it is great. What is not so great (IMHO) is the MSBuild part. Currently, all of GitVersion is centered around a "Core". But for MSBuild, that does not make much sense. It uses none of the programmatic API. It just adds some (basic) tasks, which are MSBuild-only and therefore should not be in the Core at all.

Ideally , MSBuild should be "standalone", written in netstandard2.0. Then is fine to have the "Core API" and the CLI tool using .NET 8+. It is up to you if you want to "embed" the pre-compiled CLI tool in the MSBuild package, or require the tool to be installed separately (like I did).

I also agree that the WriteVersionInfoToBuildLog task (which I made a no-op) and UpdateAssemblyInfo (which I omitted) are no longer required as tasks. All that remains is a simple task to run the CLI tool, and one that generates the GitVersionInformation class (for multiple languages, of course, not just for C# like I did).

If my attempt could somehow be merged back into GitTools/GitVersion I would be very happy.

@arturcic
Copy link
Member

arturcic commented Dec 4, 2024

@arturcic Thanks for the elaborate reasoning. I don't want to fork, I just had to in order to prevent all kinds of workarounds for using Visual Studio. I have been using GitVersion for years, and will keep using it because it is great. What is not so great (IMHO) is the MSBuild part. Currently, all of GitVersion is centered around a "Core". But for MSBuild, that does not make much sense. It uses none of the programmatic API. It just adds some (basic) tasks, which are MSBuild-only and therefore should not be in the Core at all.

Ideally , MSBuild should be "standalone", written in netstandard2.0. Then is fine to have the "Core API" and the CLI tool using .NET 8+. It is up to you if you want to "embed" the pre-compiled CLI tool in the MSBuild package, or require the tool to be installed separately (like I did).

I also agree that the WriteVersionInfoToBuildLog task (which I made a no-op) and UpdateAssemblyInfo (which I omitted) are no longer required as tasks. All that remains is a simple task to run the CLI tool, and one that generates the GitVersionInformation class (for multiple languages, of course, not just for C# like I did).

If my attempt could somehow be merged back into GitTools/GitVersion I would be very happy.

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

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

No branches or pull requests