When using the alias ParseAssemblyInfo, it returns null values if the AssemblyInfo.cs file was generated by MonoDevelop even though the file appears to be valid.
MonoDevelop is adding an extra space between the attribute name and the opening parenthesis.
[assembly: AssemblyTitle ("AssemblyTitle")]
When using ParseAssemblyInfo, its regular expressions should allow for whitespace between the attribute name and opening parenthesis.
I can create a pull request if accepted.
Cake 0.12.0
64-bit
Windows, Linux, Mac
Jenkins, TeamCity
Use ParseAssemblyInfo to parse an AssemblyInfo.cs file containing:
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("AssemblyTitle")]
[assembly: AssemblyDescription ("AssemblyDescription")]
[assembly: AssemblyConfiguration ("")]
[assembly: AssemblyCompany ("")]
[assembly: AssemblyProduct ("")]
[assembly: AssemblyCopyright ("Copyright")]
[assembly: AssemblyTrademark ("")]
[assembly: AssemblyCulture ("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
AssemblyDescription will be null.
@pvwichen found what's casuing it, file above adds an space between attribute and parentheses which apparently breaks the parser.
VisualStudio doesn't add these spaces, so there seems to be a slight indiscretion between MonoDevelop and VS.
I created a gist with a small test case here as reference when sorting issue.
Basically:
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle ("AssemblyTitle")]
[assembly: AssemblyDescription ("AssemblyDescription")]
[assembly: AssemblyConfiguration ("Configuration")]
[assembly: AssemblyCompany ("Company")]
[assembly: AssemblyProduct ("Product")]
[assembly: AssemblyCopyright ("Copyright")]
[assembly: AssemblyTrademark ("Trademark")]
[assembly: AssemblyCulture ("en-US")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
will fail but this will succeed:
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("AssemblyTitle")]
[assembly: AssemblyDescription("AssemblyDescription")]
[assembly: AssemblyConfiguration("Configuration")]
[assembly: AssemblyCompany("Company")]
[assembly: AssemblyProduct("Product")]
[assembly: AssemblyCopyright("Copyright")]
[assembly: AssemblyTrademark("Trademark")]
[assembly: AssemblyCulture("en-US")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
Test case will output
Fail:
{
"ClsCompliant": false,
"Company": "",
"ComVisible": false,
"Configuration": "",
"Copyright": "",
"Description": "",
"AssemblyFileVersion": "1.0.0.0",
"Guid": "",
"AssemblyInformationalVersion": "1.0.0.0",
"Product": "",
"Title": "",
"Trademark": "",
"AssemblyVersion": "1.0.0.0",
"InternalsVisibleTo": []
}
Success:
{
"ClsCompliant": false,
"Company": "Company",
"ComVisible": false,
"Configuration": "Configuration",
"Copyright": "Copyright",
"Description": "AssemblyDescription",
"AssemblyFileVersion": "1.0.0.0",
"Guid": "",
"AssemblyInformationalVersion": "1.0.0.0",
"Product": "Product",
"Title": "AssemblyTitle",
"Trademark": "Trademark",
"AssemblyVersion": "1.0.*",
"InternalsVisibleTo": []
}
@pvwichen this was a simple change to the regular expression that is used to extract the data. I have created a PR to correct this, and to add some more tests around how it is parsed.
@pvwichen this should be fixed in the next release of Cake, 0.13.0.
Most helpful comment
@pvwichen this should be fixed in the next release of Cake, 0.13.0.