zoukankan      html  css  js  c++  java
  • embed git commit hash to assembly

    https://stackoverflow.com/a/41200059/3782855

    https://github.com/304NotModified/Fody.Stamp

    .NET Revision Task for MSBuild

    https://stackoverflow.com/a/59900651/3782855

    https://github.com/ygoe/NetRevisionTask

    Usage in C# source code

    The following sample code from the AssemblyInfo.cs file would be resolved as described.

    [assembly: AssemblyVersion("0.0")]
    [assembly: AssemblyInformationalVersion("1.{c:15m:2013}-{chash:6}-{c:ymd}")]
    

    Result:

    [assembly: AssemblyVersion("1.93.42")]
    [assembly: AssemblyInformationalVersion("1.93.42-45d4e3-20130401")]
    

    Only C# and VB.NET projects and source files can be patched. Other source code language files are not found. This restriction should not apply to new-style simplified projects (like .NET Core).

    MSBuild properties

    Configuration of the version scheme is done through MSBuild properties defined in the project file to which the NuGet package was added. If you have multiple projects in your solution, you’d basically have to repeat these steps for each project, or you could factor them out into a separate .props file and import that into each project. This also applies to classic-style projects, even though editing the project file is a bit more involved.

    Customize your build

    MSBuild projects that use the standard build process (importing Microsoft.Common.props and Microsoft.Common.targets) have several extensibility hooks that you can use to customize your build process.

    Directory.Build.props and Directory.Build.targets

    Prior to MSBuild version 15, if you wanted to provide a new, custom property to projects in your solution, you had to manually add a reference to that property to every project file in the solution. Or, you had to define the property in a .props file and then explicitly import the .props file in every project in the solution, among other things.

    However, now you can add a new property to every project in one step by defining it in a single file called Directory.Build.props in the root folder that contains your source. When MSBuild runs, Microsoft.Common.props searches your directory structure for the Directory.Build.props file (and Microsoft.Common.targets looks for Directory.Build.targets). If it finds one, it imports the property. Directory.Build.props is a user-defined file that provides customizations to projects under a directory.

    实例

    https://github.com/kerryjiang/SuperSocket/pull/344

    NetRevisionTask

    Dotted-decimal: Generates regular dotted version numbers with two segments. The first describes the days since the base year, the second the number of intervals since midnight (UTC). This scheme consists of multiple colon-separated values: interval length, base year.

    The interval length is a number followed by “s” for seconds, “m” for minutes, “h” for hours, or “d” for days. Practical intervals are “15m” (2 digits), “2m” (3 digits).

    A shortcut to the 15-minute interval is {dmin:<year>}.

    {c:15m:2013}

    PS D:GitHubChuckLuConcurrentTestAppConcurrentTestAppinDebug> [System.Diagnostics.FileVersionInfo]::GetVersionInfo("ConcurrentTestApp.exe").ProductVersion
    1.2688.39-af72c5-20200512

    2688是天数,39是interval

  • 相关阅读:
    差分序列
    蓝桥杯 操作格子
    线段树
    历届题目 密文搜索
    对局匹配(动态规划)
    历届试题 分巧克力(二分查找)
    第九届蓝桥杯B组决赛 调手表(完全背包)
    快速幂求余
    2019蓝桥杯国赛备赛题库
    ubuntu16.04安装cuda8.0试错锦集
  • 原文地址:https://www.cnblogs.com/chucklu/p/9996717.html
Copyright © 2011-2022 走看看