Skip to content
This repository was archived by the owner on Dec 18, 2017. It is now read-only.

Victorhu/fileversion #1529

Merged
merged 1 commit into from
Mar 30, 2015
Merged

Victorhu/fileversion #1529

merged 1 commit into from
Mar 30, 2015

Conversation

victorhurdugaci
Copy link
Contributor

Inject the file version attribute in the generated assembly, only if the attribute is not already present.

Goes together with aspnet/Universe#192 and fixes #1504

Please review: @davidfowl, @anurse, @pranavkm, @ChengTian
Please note this is for beta4/release branch

@ghost ghost added the cla-not-required label Mar 28, 2015

// If the assembly version is empty then set the version
if (compilation.Assembly.Identity.Version == emptyVersion)
var addAttributeIfNotExists = new Action<string, string>((attributeName, attributeValue) =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make this a regular method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less arguments :)

@victorhurdugaci
Copy link
Contributor Author

@pranavkm updated the PR. please take a look

}
catch(FormatException ex)
{
throw new FormatException("The assembly file version is invalid: " + fileVersion, ex);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah. Just use Version.Parse and let that throw.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah. The error message is really bad. It just says that the string has an invalid format but doesn't tell you what the value is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then at least fix the formatting in the file 😄

@victorhurdugaci
Copy link
Contributor Author

Updated

{
try
{
project.AssemblyFileVersion = new Version(fileVersion);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe Version.TryParse instead of try-catching?

@pranavkm
Copy link
Contributor

:shipit: once somebody from DNX signs off.

}
catch (FormatException ex)
{
throw new FormatException("The assembly file version is invalid: " + fileVersion, ex);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using String.Format instead of concat.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't the exception message have to be localizable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strings in the runtime are localizable. I think there is an issue about that somewhere...

@muratg
Copy link
Contributor

muratg commented Mar 30, 2015

/cc: @joeloff

:shipit:

@victorhurdugaci
Copy link
Contributor Author

Updated the PR with one change: the prefix for the version is picked up from the project.json file.

@victorhurdugaci victorhurdugaci merged commit a50b85c into release Mar 30, 2015
@victorhurdugaci victorhurdugaci deleted the victorhu/fileversion branch March 30, 2015 22:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants