Skip to content

Get version via reflection #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RabbitMQ.Stream.Client/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -845,4 +845,4 @@ static RabbitMQ.Stream.Client.StreamCompressionCodecs.RegisterCodec<T>(RabbitMQ.
static RabbitMQ.Stream.Client.StreamCompressionCodecs.UnRegisterCodec(RabbitMQ.Stream.Client.CompressionType compressionType) -> void
static RabbitMQ.Stream.Client.StreamSystem.Create(RabbitMQ.Stream.Client.StreamSystemConfig config) -> System.Threading.Tasks.Task<RabbitMQ.Stream.Client.StreamSystem>
static RabbitMQ.Stream.Client.SubEntryPublish.Version.get -> byte
static readonly RabbitMQ.Stream.Client.Version.VersionString -> string
static RabbitMQ.Stream.Client.Version.VersionString.get -> string
26 changes: 0 additions & 26 deletions RabbitMQ.Stream.Client/RabbitMQ.Stream.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,4 @@
<PackageReference Include="System.IO.Pipelines" Version="6.0.2" />
</ItemGroup>

<Target Name="AfterMinVer" AfterTargets="MinVer">
<SetLibraryVersion Version="$(MinVerVersion)" />
</Target>

<UsingTask TaskName="SetLibraryVersion" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Version ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
string pattern = "VersionString = \"[^\"]+\";";
string replacement = string.Format("VersionString = \"{0}\";", Version);
Regex rx = new Regex(pattern);
string text = File.ReadAllText("Version.cs");
string repl = rx.Replace(text, replacement);
File.WriteAllText("Version.cs.tmp", repl, Encoding.UTF8);
File.Replace("Version.cs.tmp", "Version.cs", "Version.cs.bak");
]]>
</Code>
</Task>
</UsingTask>

</Project>
14 changes: 13 additions & 1 deletion RabbitMQ.Stream.Client/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
// 2.0, and the Mozilla Public License, version 2.0.
// Copyright (c) 2007-2020 VMware, Inc.

using System.Diagnostics;
using System.Reflection;

namespace RabbitMQ.Stream.Client
{
public static class Version
{
public static readonly string VersionString = "1.0.0-beta.5.8";
private static readonly string _versionString;

static Version()
{
var a = Assembly.GetAssembly(typeof(Version));
var fvi = FileVersionInfo.GetVersionInfo(a.Location);
_versionString = fvi.ProductVersion;
}

public static string VersionString => _versionString;
}
}