Skip to content

GitVersionTaskAssemblyInfo.g.cs Conflict with Project Namespace #709

@sponge-b0b

Description

@sponge-b0b

My project has a namespace like Foo.System. Since you use the fully qualified namespace of the attribute [System.Runtime.CompilerServices.CompilerGenerated] for the GitVersionInformation class and since it is nested within the Foo.System namespace of my project it won't compile because the compiler is looking for a Runtime namespace within Foo.System which doesn't exist. The solution is to add a using System.Runtime.CompilerServices; line and adorn the class with just [CompilerGenerated] like so:

using System;
using System.Reflection;
using System.Runtime.CompilerServices;  // Add this line

[assembly: AssemblyVersion(""{0}"")]
[assembly: AssemblyFileVersion(""{1}"")]
[assembly: AssemblyInformationalVersion(""{2}"")]

namespace Foo.System
{
    // Modify this line
    // Compiler sees this line as [Foo.System.Runtime.CompilerServices.CompilerGenerated], there is no Runtime in Foo.System
    [System.Runtime.CompilerServices.CompilerGenerated]

    // To this
    [CompilerGenerated]
    static class GitVersionInformation

Now there is no more conflict. Ideally it would be nice if the auto-generation of GitVersionInformation was configurable and not hard-coded in AssemblyInfoBuilder.cs. Or if you provided a template file for GitVersionTaskAssemblyInfo.g.cs that could be customized.

Thank you for your help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions