GithubHelp home page GithubHelp logo

tagc / dotnet-setversion Goto Github PK

View Code? Open in Web Editor NEW
73.0 3.0 16.0 74 KB

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

License: MIT License

C# 100.00%
net-core csproj-tooling dotnet-cli versioning

dotnet-setversion's Introduction

dotnet-setversion is a simple .NET Core CLI tool used to update the version information within .NET Core *.csproj files.

It is based on dotnet-gitversion, but is updated to work for the new *.csproj format instead of project.json, and relies on the version information being passed to it.

NuGet Build status

Usage

Install dotnet-setversion as a global tool using the dotnet CLI:

$ dotnet tool install -g dotnet-setversion

If the command completed successfully, you're able to invoke dotnet-setversion in any directory like this:

$ setversion 0.1.2-beta0001

You can also update the version information of a specific project file by invoking like this:

$ setversion 0.1.2-beta0001 MyProject.csproj

Recursive updates

If you happen to have a rather big repo including several project files and you want to update them all at once, you can use the --recursive option.
This will update any project file in and below the current working directory.

$ setversion -r 0.1.2-beta0001

Extracting the version from a file

As well as passing the version directly, you can specify a file to extract the version number from. This is done by prefixing the version argument with an @ symbol. For example, the following command will make the tool try to extract the version from a file in the working directory called "sem.ver".

$ setversion @sem.ver

The file should represent the version either as a simple string (i.e. in the same format you'd ordinarily provide directly to the tool, such as 0.1.2) or in JSON format using a schema like this:

{
  "Version": {
    "Major": 0,
    "Minor": 1,
    "Patch": 2
  }
}

Bear in mind that the JSON format does not support metadata extensions (e.g. -beta0001).

Further notes

For each example, replace '0.1.2-beta0001' with any valid version string or, when having GitVersion installed, with $(GitVersion -ShowVariable NuGetVersionV2) to use your current version automatically.

This (or something similar) can of course be done during a continuous integration build, which is the main intention behind developing this project. This tool depends on itself for its own version management during CI builds, so you can use it as a reference.

Migrating from 1.* to 2.*

dotnet-setversion used to be a per-project tool, but has now been reworked as a .NET Core Global Tool.
As a consequence of this, you have to remove the <DotNetCliToolReference> element referencing dotnet-setversion or you'll get an error when running dotnet restore.

Depending on your build strategy, you have to install setversion once on your build agent (see Usage) or integrate the install command into your build script.

Finally you have to change the way to invoke the program from dotnet setversion to setversion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.