Skip to content

Duplicate Assembly attribute error when using constants #1212

@fvanzee

Description

@fvanzee

Related to #871 and #760

Using a shared assembly info I am setting my version number in a constant string

[assembly: AssemblyVersion(AssemblyInfo.Version)]
[assembly: AssemblyFileVersion(AssemblyInfo.FileVersion)]
[assembly: AssemblyInformationalVersion(AssemblyInfo.InformationalVersion)]

Looking at the RegEx to replace the attributes, this is not going to work as it requires quotation marks in the between the parentheses of the attribute.

This of course results in duplicate Assembly attributes, as it will try to append new attributes, assuming there are none.

I don't understand why the RegEx in AssemblyInfoFileUpdate.cs requires the quotation marks
RegEx:
AssemblyVersion(Attribute)?\s*\(\s*"[^""]*"\s*\)

Would it not be better to just replace any content (including whitespace) between the parentheses of the Attribute?
RegEx:
AssemblyVersion(Attribute)?\s*\(\s*\S*\s*\)

Of course, the string that's replacing the original should then have the quotation marks again.
Probably this would require some refactoring on AssemblyInfoFileUpdate.cs and maybe some other places. I'm glad to make a PR, does anyone see any issues with this?

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