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

[ISSUE]: GitVersion MSBuild v.6.0.2 does not generate AssemblyInfo.g.cs needed to override AssemblyVersion #4190

Closed
2 tasks done
seandkim opened this issue Sep 2, 2024 · 3 comments
Labels

Comments

@seandkim
Copy link

seandkim commented Sep 2, 2024

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.2

Operating system

Windows

What are you seeing?

I have a simple console app with the following:
Program.cs

using System.Reflection;
var version = Assembly.GetExecutingAssembly()
    .GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
Console.WriteLine($"Hello, World! {version}");

.csproj file

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net8.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="GitVersion.MsBuild" Version="6.0.2">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
</Project>

I added a git tag so my gitversion output is

{
  "AssemblySemFileVer": "2.3.1.0",
  "AssemblySemVer": "2.3.1.0",
  "BranchName": "master",
  "BuildMetaData": null,
  "CommitDate": "2024-09-02",
  "CommitsSinceVersionSource": 0,
  "EscapedBranchName": "master",
  "FullBuildMetaData": "Branch.master.Sha.7ced748ec0ba476224b74e34581bf0ad0e141088",
  "FullSemVer": "2.3.1",
  "InformationalVersion": "2.3.1+Branch.master.Sha.7ced748ec0ba476224b74e34581bf0ad0e141088",
  "Major": 2,
  "MajorMinorPatch": "2.3.1",
  "Minor": 3,
  "Patch": 1,
  "PreReleaseLabel": "",
  "PreReleaseLabelWithDash": "",
  "PreReleaseNumber": null,
  "PreReleaseTag": "",
  "PreReleaseTagWithDash": "",
  "SemVer": "2.3.1",
  "Sha": "7ced748ec0ba476224b74e34581bf0ad0e141088",
  "ShortSha": "7ced748",
  "UncommittedChanges": 2,
  "VersionSourceSha": "7ced748ec0ba476224b74e34581bf0ad0e141088",
  "WeightedPreReleaseNumber": 60000
}

What is expected?

I expect to see my gitversion; instead, I see the default assembly version, v1.0.0. I noticed that AssemblyInfo.g.cs file is not generated when I run dotnet build.

The problem only occurs in v6.0.2. In v5.12.0, the gitversion is correctly outputted (and AssemblyInfo.g.cs file correctly autogenerated).

Steps to Reproduce

See above

RepositoryFixture Test

No response

Output log or link to your CI build (if appropriate).

No response

@seandkim seandkim changed the title [ISSUE]: GitVersion MSBuild v.6.0.2 does not generate AssemblyInfo.g.cs [ISSUE]: GitVersion MSBuild v.6.0.2 does not generate AssemblyInfo.g.cs needed to override AssemblyVersion Sep 2, 2024
@arturcic
Copy link
Member

arturcic commented Sep 5, 2024

@seandkim can you tell me how are you building the code? Is it via dotnet build or visual studio?

@neoasis-werx
Copy link

neoasis-werx commented Sep 5, 2024

I'm having the same issue, It works using dotnet build.

But when building in VisualStudio 2022, it does not create the

  • gitversion.json
  • GitVersionInformation.g.cs
  • or modifies the AsssemblyInfo.cs
Microsoft Visual Studio Enterprise 2022 (64-bit) - Current
Version 17.11.2
.Net 8.0.400

when Reverting back to 5.12 everything works.

@arturcic
Copy link
Member

arturcic commented Sep 5, 2024

the issue is has same root as #4116. GitVersion.MsBuild is disabled when run in Visual Studio, so I will close this issue in favor of the mentioned

@arturcic arturcic closed this as completed Sep 5, 2024
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

3 participants