I'm developing an ASP.Net Core project, where the .csproj file looks like this:
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>dummyapp</AssemblyName>
<Version>17.12.1</Version>
<RuntimeIdentifiers>centos.7-x64;win7-x64</RuntimeIdentifiers>
</PropertyGroup>
When this app is published for Windows, I can get the version info from its properties. Which shows 17.12.1 as mentioned.
Alternatively I can run wmic datafile where name="filepath/app.exe" get Version /value
and get the same version using command prompt.
But is there a standard way to get the same in linux distro?
I've looked into:
how-to-find-version-of-a-file-or-program
Experimented with this answer. Though it is for file-system!
Tried myapp --version
and /fullpath/myapp --version
as mentioned in this post. Also tried solutions with the marked duplicates.
After all the trials, it seems, I need to implement something else in the .csproj
file so as to get the version info using bash. Can someone point out what needs to be done, or give a hint about the same.
Main
method:
public static void Main(string[] args)
{
var root = new Root();
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile(SettingsFilename, optional: false,
reloadOnChange: true)
.AddEnvironmentVariables()
.Build();
config.Bind(root);
//some codes
var host = new WebHostBuilder()
.UseKestrel()
.UseUrls(root.AppUrl)
.UseConfiguration(config)
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.ConfigureServices(s =>
s.AddRouting().DetectTokenChange(config))
.UseSetting(WebHostDefaults.ApplicationKey, "dummyapp")
.Configure(app => app.UseRouter(r => r.MapPost("dumptoqueue",
async (context) =>
await Task.Run(() => AddtoQueue(context)))))
.Build();
host.Run();
}
App built using the command line:
dotnet publish -c release -r centos.7-x64
It might just be easier to use exiftool
, if all you need to do via bash is to find the version of a dll file.
$ exiftool Foo.dll | grep -i Version
ExifTool Version Number : 10.55
Linker Version : 48.0
OS Version : 4.0
Image Version : 0.0
Subsystem Version : 4.0
File Version Number : 17.12.1.0
Product Version Number : 17.12.1.0
File Version : 17.12.1.0
Product Version : 17.12.1
Assembly Version : 17.12.1.0
Or even just:
$ exiftool -"ProductVersion" Foo.dll
Product Version : 17.12.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With