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

  • 相关阅读:
    gdb查看内存(转)
    c++ 前置++与后置++的区别
    stl第二级空间配置器详解(1)
    stl空间配置器简介
    套接字描述符就绪条件
    针对TCP连接异常断开的分析
    linux僵尸进程产生的原因以及如何避免产生僵尸进程
    k8s istio 配置域名转发到外部节点机器上
    tinymce增加mathjax 支持数学公式录入渲染
    vue 配置 TinyMCE
  • 原文地址:https://www.cnblogs.com/chucklu/p/9996717.html
Copyright © 2011-2022 走看看