CnCNet / xna-cncnet-client

XNA / MonoGame based client for playing classic Command & Conquer games both online and offline with a CnCNet game spawner.
Other
224 stars 85 forks source link

Add gitversion #403

Closed devo1929 closed 1 year ago

github-actions[bot] commented 1 year ago

Nightly build for this pull request:

devo1929 commented 1 year ago

I strongly suggest having all assemblies versioned, not just DXMainClient.

Will do.

frg2089 commented 1 year ago

Try used this?


  <!-- Generate BuildStamp -->
  <Target Name="GenerateBuildStamp" BeforeTargets="GetAssemblyAttributes">
    <!-- This code fragment follows the MIT license agreement. -->
    <!-- Git Commit Hash -->
    <Exec Command="git rev-parse --short HEAD" ConsoleToMsBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="__GitRevision" />
    </Exec>

    <!-- Git Branch -->
    <Exec Command="git rev-parse --symbolic-full-name --abbrev-ref HEAD" ConsoleToMsBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="__GitBranch" />
    </Exec>

    <ItemGroup>
      <AssemblyMetadata Include="BuildTime" Value="$([System.DateTime]::Now.ToString('O'))" />
      <AssemblyMetadata Include="Revision" Value="$(__GitRevision)" />
      <AssemblyMetadata Include="Branch" Value="$(__GitBranch)" />
    </ItemGroup>
  </Target>
devo1929 commented 1 year ago

I strongly suggest having all assemblies versioned, not just DXMainClient.

Done.

devo1929 commented 1 year ago

Try used this?

  <!-- Generate BuildStamp -->
  <Target Name="GenerateBuildStamp" BeforeTargets="GetAssemblyAttributes">
    <!-- This code fragment follows the MIT license agreement. -->
    <!-- Git Commit Hash -->
    <Exec Command="git rev-parse --short HEAD" ConsoleToMsBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="__GitRevision" />
    </Exec>

    <!-- Git Branch -->
    <Exec Command="git rev-parse --symbolic-full-name --abbrev-ref HEAD" ConsoleToMsBuild="true">
      <Output TaskParameter="ConsoleOutput" PropertyName="__GitBranch" />
    </Exec>

    <ItemGroup>
      <AssemblyMetadata Include="BuildTime" Value="$([System.DateTime]::Now.ToString('O'))" />
      <AssemblyMetadata Include="Revision" Value="$(__GitRevision)" />
      <AssemblyMetadata Include="Branch" Value="$(__GitBranch)" />
    </ItemGroup>
  </Target>

Are you suggesting this instead of using the gitversion tool? The gitversion tool provides the GitBranch and the GitRevision also, but doesn't provide the build datetime. However, it does include the commit date.

The main need for this is the auto semantic versioning X.Y.Z. Hoping to get this into nuget so that mods can consume it as a dependency rather than having to manually copy/paste binaries around.

Metadorius commented 1 year ago

Heads up, mod authors usually don't even know what NuGet is, and for them the word "Git" means a cryptic website where it's hard to download something usually 🤣

devo1929 commented 1 year ago

Heads up, mod authors usually don't even know what NuGet is, and for them the word "Git" means a cryptic website where it's hard to download something usually 🤣

That's fine. We'll continue to provide the current method which is to download the artifacts from the build manually, but for those that know how to use NuGet can 😄

frg2089 commented 1 year ago

The main need for this is the auto semantic versioning X.Y.Z. Hoping to get this into nuget so that mods can consume it as a dependency rather than having to manually copy/paste binaries around.

In fact, it does not contain a binary file. It only needs git in the path. We can use the FileVersion and AssemblyVersion properties to generate X.Y.Z style versions.

like this

<PropertyGroup>
  <FileVersion>X.$(__GitBranch).$(__GitRevision)</FileVersion>
  <AssemblyVersion>$(FileVersion)</AssemblyVersion>
</PropertyGroup>
devo1929 commented 1 year ago

The main need for this is the auto semantic versioning X.Y.Z. Hoping to get this into nuget so that mods can consume it as a dependency rather than having to manually copy/paste binaries around.

In fact, it does not contain a binary file. It only needs git in the path. We can use the FileVersion and AssemblyVersion properties to generate X.Y.Z style versions.

What doesn't contain a binary file? Using YR as an example, we distribute client updates by using a separate repo. We have to download the latest build binaries from the client repo and then put them into the YR repo. I'd rather have the option to reference a nuget package so that I can script it to automatically download the binaries from Nuget.

Gitversion auto generates the FileVersion and AssmemblyVersion as well. It uses the number of commits since the latest tag that the current branch is based off of to calculate what it should be, rather than us having to manually increment any part of it. Sure, we can calculate these things ourselves, but this tool does all of that for us. No need to rebuild what's already available to us.