node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

gulp-dotnet-assembly-info

gulp-dotnet-assembly-info

npm version build status Dependency Status npm downloads

Gulp plugin for modifying C# assembly info files.

Install

$ npm install gulp-dotnet-assembly-info --save

Usage

Simply pass in an object containing the attibutes and their replacements. The replacement can be a value or a function. A function is passed the value specified in the original assembly info file and returns the replacement value. The convention for attribute names is the name without the Assembly prefix and camel cased. So an attribute name of fileVersion will be converted to AssemblyFileVersion. The files can simply be replaced by piping them to the same location (.pipe(gulp.dest('.'))) or to a new location.

var gulp = require('gulp'),
    assemblyInfo = require('gulp-dotnet-assembly-info');
 
gulp.task('assemblyInfo', function() {
    gulp.src('**/AssemblyInfo.cs')
        .pipe(assemblyInfo({
            title: 'Planet Express Website',
            description: 'Shipping and tracking website.', 
            configuration: 'Release', 
            company: 'Planet Express', 
            product: 'Planet Express Website', 
            copyright: 'Copyright 3002 © Planet Express', 
            trademark: 'Planet Express', 
            culture: 'div-MV',
            version: function(value) { return value + '.2345'; },
            fileVersion: function(value) { return '2.0.3.2345'; },
            ...
        }))
        .pipe(gulp.dest('.'));
});

You can also use the plugin to read the data from assembly info file:

var gulp = require('gulp'),
     fs = require('fs'),
    assemblyInfo = require('gulp-dotnet-assembly-info');
 
gulp.task('readAssemblyInfo', function () {
 
    var assemblyInfoFileContents = fs.readFileSync('./properties/AssemblyInfo.cs', "utf8");
    var assembly = assemblyInfo.getAssemblyMetadata(assemblyInfoFileContents);
    console.log("Current version is: " + assembly.AssemblyVersion);
    
});
 

Props

Thanks to Diego Luces for adding VB.NET support.

License

MIT License