Automatically update the AssemblyFileVersion attribute of a .NET Assembly

Automatic AssemblyFileVersion Updates
Automatic AssemblyFileVersion Updates

There is support in .NET for automatically incrementing the AssemblyVersion of a project by using the “.*” notation. e.g.
[assembly: AssemblyVersion("0.1.*")]

Unfortunately the same functionality isn’t available for the AssemblyFileVersion. Often times, I don’t want to bump the AssemblyVersion of an assembly as it will effect the strong name signature of the assembly, and perhaps the changes (a bug fix) isn’t significant enough to warrant it. However I do want to automatically increment the file version, so that in a deployed environment, I can right click the file and establish when the file was built & released.

[important]Enter the Update-AssemblyFileVersion.ps1 file.[/important]

This powershell script, (heavily borrowed from David J Wise’s article), runs as a pre-build command on a .NET Project. Simply point the command at an assembly info file, (or GlobalAssemblyInfo.cs if you’re following my suggested versioning tactics)  and ta-da, automatically updating AssemblyFileVersions.

The Build component of the version number will be set using the following formula based on a daycount since the year 2000.

# Build = (201X-2000)*366 + (1==>366)
#
    $build = [int32](((get-date).Year-2000)*366)+(Get-Date).DayOfYear
 

The Revision component of the version number will be using the following formula based on seconds in the current day.

# Revision = (1==>86400)/2 # .net standard
#
    $revision = [int32](((get-date)-(Get-Date).Date).TotalSeconds / 2)
 

The Major & Minor components are not set to update although they could be. Simply add the following command to your Pre-Build event and you’re all set.

%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe 
    -File "C:\Path\To\Update-AssemblyFileVersion.ps1"  
    -assemblyInfoFilePath "$(SolutionDir)\Project\Properties\AssemblyInfo.cs"

~Eoin C

nuget.org

Combinatorics in .NET – Part II – Creating a Nuget Package

nuget.org
nuget.org
[important] This is part 2 of a 2 part post on Combinatorics in .Net

The solution is publicly available on github; https://github.com/eoincampbell/combinatorics

The library can be added to any .NET Soution via Nuget; https://nuget.org/packages/Combinatorics
[/important]

In the last post we looked at the Combinatorics Library, a .NET Assembly which provides Combinatoric generation capabilities to your .NET Applications. Now lets look at bundling up that solution & deploying the package to Nuget. Nuget is an online .NET Package Repository & associated Visual Studio extension that makes it easy to manage external assemblies in your projects. Developers who build 3rd party libraries or tools can create a NuGet package and store the package in a NuGet repository. Other developers can then browse the repository (online or with Visual Studio) and add references to those 3rd party tools & libraries.

You can read more about Nuget here.

Read More “Combinatorics in .NET – Part II – Creating a Nuget Package”

How many combinations ?

Combinatorics in .NET – Part I – Permutations, Combinations & Variations

How many combinations?
How many combinations?
[important] This is part 1 of a 2 part post on Combinatorics in .Net

The solution is publicly available on github; https://github.com/eoincampbell/combinatorics

The library can be added to any .NET Soution via Nuget; https://nuget.org/packages/Combinatorics
[/important]

 

Recently while working on a project, I had need to generate combintations and permutations of sets of Inputs. In my search for a decent combinatorics library for .NET, (something which is missing from the BCL), I came across a Codeproject Article from Adrian Akision. The implementation included a C# Generics Collection implementation for creating Combinations, Permutations & Variations from an Input Set. Adrian very graciously allowed that I bundle up the code as a Class Library Solution on Github & then release the library via Nuget.

Read More “Combinatorics in .NET – Part I – Permutations, Combinations & Variations”

Cyclic Reference

Xml & Json Serialization of Object Graphs with Cyclic References in .NET

Cyclic Reference
Cyclic Reference

As a WCF Developer you’ve no doubt run into some issues with object serialization at some point or another during the course of developing your applications. Either during the course of pushing your entities through a WCF Service or by attempting to serialize those object for transit through other media. Recently I ran into some issues around serializing WCF Entities with Circular References (or cyclic relationships) between parent & child Objects.

Background

A large percentage of our company’s software work relies on moving a variety of object graphs around through WCF. These object graphs, often times contain self-references or circular references. The data we deal with is primarily related to the airline industry; specifically crew & flight schedules. It contains complicated tree structures of data with information on the flights crew-member’s fly, the duties (work-shifts) those flights belong to & the pairings, those duties are contained within. (A pairing is airline industry parlance for a collection of Duties organised into a longer 4 or 5 scheduled body of work for a crew member. Confusingly, it is not necessarily a Pair of anything).

In order to allow us to more easily navigate these object graphs, we populate a number of helper properties on the entities to allow us to traverse up and down the graph with ease. The following is an extremely simplified example of what gets populated in our Crew Schedule “Roster” Object Graph and shows the relations ships between the three previously mentioned domain entities.

Of course, this makes for some interesting cyclic situations when both the parent objects & contents of the child collections are cross-wired to one another and we want to serialize those objects for use through a WCF Service.

Read More “Xml & Json Serialization of Object Graphs with Cyclic References in .NET”