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

ParseAssemblyInfo does not support .NET Core generated assembly info #2473

Closed
Joev- opened this Issue Feb 14, 2019 · 4 comments

Comments

Projects
None yet
3 participants
@Joev-
Copy link

commented Feb 14, 2019

What You Are Seeing?

When parsing an AssemblyInfo file generated by the .NET Core SDK on build no information is returned. e.g. AssemblyInformationalVersion returns the default value of 1.0.0 rather than my specified version.

What is Expected?

The correct information is returned.

What version of Cake are you using?

0.32.1

Are you running on a 32 or 64 bit system?

64bit

What environment are you running on? Windows? Linux? Mac?

Windows

Are you running on a CI Server? If so, which one?

No

How Did You Get This To Happen? (Steps to Reproduce)

Parse the generated AssemblyInfo file using ParseAssemblyInfo

var assemblyInfo = ParseAssemblyInfo("obj/Debug/netcoreapp2.2/win-x64/MyProject.AssemblyInfo.cs");
Information("Version: {0}", assemblyInfo.AssemblyVersion);
Information("File version: {0}", assemblyInfo.AssemblyFileVersion);
Information("Informational version: {0}", assemblyInfo.AssemblyInformationalVersion);   

Output Log

Not necessary

The reason this is not working is that the generated AssemblyInfo in .NET Core projects uses the full attribute type name rather than the typically shortened type name. Cake uses the shorter name as seen here whereas .NET core Projects will have System.Reflection.AssemblyInformationalVersionAttribute in the generated file.

An alternative regex that would work for all cases would be this: https://regex101.com/r/Teupyl/1 and modified to allow for the string format substitution:

^\s*\[assembly: (?:System\.Reflection\.)?{0}(?:Attribute)?\("(?<attributeValue>.*)"\)
@gep13

This comment has been minimized.

Copy link
Member

commented Feb 14, 2019

@Joev- this is known to be the case.

While there was a LOT of churn with the new project format, a parser was created here:

https://github.com/cake-contrib/Cake.Incubator

Which correctly handles the new project format.

At some point, this will be moved into Cake proper.

@Joev-

This comment has been minimized.

Copy link
Author

commented Feb 14, 2019

No problem Gary, I figured that this was the case but spent a while searching and did not come across any other references. I'll check out the Incubator.

@Joev- Joev- closed this Feb 14, 2019

@gep13

This comment has been minimized.

Copy link
Member

commented Feb 14, 2019

@Joev- actually, I might have misread your issue....

I thought you were referring to the new csproj format, not an AssemblyInfo file. I am not sure if there is a new parser for that in Incubator or not. If not, come back here and we can investigate.

Sorry to mess you around!

@Joev-

This comment has been minimized.

Copy link
Author

commented Feb 14, 2019

Not a problem at all, I did just have a look through the incubator and as you say, I didn't see anything for the AssemblyInfo file.

@Joev- Joev- reopened this Feb 14, 2019

Joev- pushed a commit to Joev-/cake that referenced this issue Feb 15, 2019

Joseph Vaughan
(cake-buildGH-2473) Support fully qualified attributes in AssemblyInfo
This change supports reading attributes from the auto generated
AssemblyInfo files in .NET Core projects.

patriksvensson added a commit that referenced this issue Feb 15, 2019

Merge pull request #2476 from Joev-/GH2473
(GH-2473) Support fully qualified attributes in AssemblyInfo

@patriksvensson patriksvensson added this to the v0.33.0 milestone Feb 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.