BoolBySigma / UpdateAssemblyInfo

SORRY THIS IS NO LONGER MAINTAINED
10 stars 9 forks source link

Using date in assembly and file version is not supported #5

Closed Kujawadl closed 7 years ago

Kujawadl commented 7 years ago

When setting the BuildNumber, tokens such as $(Year:yyyy) or $(Date:MMdd) are supported. However, these tokens are not available to build tasks, as they aren't actual build variables.

As a workaround, I am using the Transform Value task from the Variable Toolbox extension. I use a regex replace to parse the year/month/day/etc out of the build number, and pass those values into the Update Assembly Info task. However, this is a pretty clunky workaround.

Would it be possible to support date formats as inputs to the version info? Preferably, support for the following would be nice:

Token Example
$(Date:{format})* Various formats
$(DayOfYear) 217
$(Hours) 21
$(Minutes) 7
$(Rev:r) 1

* This is definitely the most useful

ghost commented 7 years ago

Published new version that supports a new $(Date:{...}) variable.

See documentation regarding the $(Date:{...}) variable on the extension page.

Please let me know how this works for you.

Kujawadl commented 7 years ago

Thanks so much for the quick response!

If it's not too much trouble, could you also add $(DayOfYear) and $(Rev) support? We don't have much need for hours/minutes, but we're planning on using something like $(Date:yy)$(DayOfYear) for our Build version and $(Rev:r) for our Revision version.

If you upload the source to GitHub I'd be happy to help out with this in my free time, though it would have to wait until this weekend.

Thanks

ghost commented 7 years ago

Hi

$(DayOfYear) is a good idea and I will go through tokens to see what else would be useful.

$(Rev) is a bit more difficult. I am yet to find a way of getting this info during build. Only way I have found so far is to add it to BuildNumber but that is not ideal. An alternative is to use BuildId but that will increment indefinately. I will look into it.

Kujawadl commented 7 years ago

Shoot, you're absolutely right about the $(Rev) token...

I know this is going to sound wayyy complicated, but it would provide some more flexibility to those who want to use it: what about adding support for regex?

For example: /$(Build.BuildNumber)/^.*_\d\d(\d\d)-(\d\d)-(\d\d)_r(\d)/$4/g would return the revision number (where the build number format is {ProjectName}_yyyy-MM-dd_r#)

I know it sounds kind of stupid, but before you added support for the date token, that's basically what I was doing anyways as a workaround: Using the build number in a regex find/replace and then setting a variable to that value to use later. If that were built into the task, we could skip the added tedium of using multiple additional tasks.

ghost commented 7 years ago

Just published new version with support for $(DayOfYear)

ghost commented 7 years ago

For now I have no plan to add regex support. I will instead continue to investigate other ways of supporting $(Rev:.rr) and will add this feature as soon as a stable solution is available.

ghost commented 7 years ago

Investigating $(Rev) support and started issue #6 if you would like to follow or participate