0

i'm using TFS 2017 for CI, Version defined in csproj file as below should be auto-incremented after every TFS build,

<PropertyGroup>
    <Major Condition=" '$(Major)' == '' ">1</Major>
    <Minor Condition=" '$(Minor)' == '' ">0</Minor>
    <Patch Condition=" '$(Patch)' == '' ">0</Patch>
    <VersionPrefix>$(Major).$(Minor).$(Patch)</VersionPrefix>
</PropertyGroup>

I added Major, Minor and Patch varibles on TFS Job, my question is how to increment these variables in TFS BUILD.

Danko Valkov
  • 1,038
  • 8
  • 17
Boubakr Echieb
  • 127
  • 1
  • 17
  • It is not directly a solution for you problem but maybe another approach. Take a look at GitVersion if you use Git and Git flow as code version system. For TFS2017 you could just use a build task. – ChW Jan 05 '18 at 14:05

3 Answers3

1

I solve the problem by using Bump to increment version in package.json file,

var gulp = require('gulp');
var bump = require('gulp-bump');

// Basic usage:
// Will patch the version
gulp.task('bump', function(){
  gulp.src('./component.json')
  .pipe(bump())
  .pipe(gulp.dest('./'));
});

// Defined method of updating:
// Semantic
gulp.task('bump', function(){
  gulp.src('./*.json')
  .pipe(bump({type:'minor'}))
  .pipe(gulp.dest('./'));
});

// Defined method of updating:
// Semantic major
gulp.task('bump', function(){
  gulp.src('./package.yml')
  .pipe(bump({type:'major'}))
  .pipe(gulp.dest('./'));
});

// Defined method of updating:
// Set a specific version
gulp.task('bump', function(){
  gulp.src('./*.json')
  .pipe(bump({version: '1.2.3'}))
  .pipe(gulp.dest('./'));
});

// Update bower, component, npm at once:
gulp.task('bump', function(){
  gulp.src(['./bower.json', './component.json', './package.json'])
  .pipe(bump({type:'major'}))
  .pipe(gulp.dest('./'));
});

// Define the key for versioning off
gulp.task('bump', function(){
  gulp.src('./package.json')
  .pipe(bump({key: "appversion"}))
  .pipe(gulp.dest('./'));
}); 

icreated 3 Jobs in TSF, evry job is responsable for incrementing one of Major, Minor and Patch, so while commiting developer will choose to excute one of these jobs, wich will excute the concrete gulp Task.

Boubakr Echieb
  • 127
  • 1
  • 17
0

If your code is stored in TFS server there is one way to update your project. I recommend update your project to .net core 2 downloading dependencies of version. Then update your project file. here is good article of updating your version.

https://www.stevejgordon.co.uk/upgrading-to-asp-net-core-2-0

0

You can try to set the build number format as $(Major).$(Minor)-rev$(Rev:.rr), then update the application version with the variable $(Build.BuildNumber)

What is $(Rev:.rr)?

To ensure that every completed build has a unique name. When a build is completed, if nothing else in the build number has changed, the Rev integer value is incremented by one.

Source:MSDN

You can use the .NET Core CLI tool to update the version information in .NET Core *.csproj files.


Other threads may helps:

Community
  • 1
  • 1
Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55
  • i'm trying to use [lProject Version Tools](https://marketplace.visualstudio.com/items?itemName=mrtarantula.projectversiontools) extension with TFS, build complete successfully but i didn't find the version in csproj file – Boubakr Echieb Jan 08 '18 at 10:16
  • @BoubakrEchieb Seems it's not available for .net core application. The version info can be retrieved from the AssemblyInfo.cs file, it is being created dynamically in the folder: `obj/Debug/netcoreapp1.1/`. See [this similar thread](https://stackoverflow.com/questions/43019832/auto-versioning-in-visual-studio-2017-net-core) for details. – Andy Li-MSFT Jan 09 '18 at 04:03