Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/core.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Lander <rlander@microsoft.com>2020-08-21 21:08:47 +0300
committerRich Lander <rlander@microsoft.com>2020-08-21 21:08:47 +0300
commitf4ddfe4f596983e3e3e01111efd58a98efd6687f (patch)
treec5ba29b501ef58b298a147d332c90ba0df869465 /samples
parent9a39b6b01eff4a2a19bf2c6da9f8762e4d07fda9 (diff)
Add dotnet-versioninfo tool
Diffstat (limited to 'samples')
-rw-r--r--samples/versioninfo/Program.cs36
-rw-r--r--samples/versioninfo/README.md28
-rw-r--r--samples/versioninfo/versioninfo.csproj21
3 files changed, 85 insertions, 0 deletions
diff --git a/samples/versioninfo/Program.cs b/samples/versioninfo/Program.cs
new file mode 100644
index 00000000..e39f61d3
--- /dev/null
+++ b/samples/versioninfo/Program.cs
@@ -0,0 +1,36 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using static System.Console;
+
+namespace versioninfo
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ WriteLine("**.NET Core information");
+ WriteLine($"{nameof(Environment.Version)}: {Environment.Version}");
+ WriteLine($"{nameof(RuntimeInformation.FrameworkDescription)}: {RuntimeInformation.FrameworkDescription}");
+ WriteLine($"Libraries version: {((AssemblyInformationalVersionAttribute[])typeof(object).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute),false))[0].InformationalVersion.Split('+')[0]}");
+ WriteLine($"Libraries hash: {((AssemblyInformationalVersionAttribute[])typeof(object).Assembly.GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false))[0].InformationalVersion.Split('+')[1]}");
+ WriteLine();
+ WriteLine("**Environment information");
+ WriteLine($"{nameof(RuntimeInformation.OSDescription)}: {RuntimeInformation.OSDescription}");
+ WriteLine($"{nameof(Environment.OSVersion)}: {Environment.OSVersion}");
+ WriteLine($"{nameof(RuntimeInformation.OSArchitecture)}: {RuntimeInformation.OSArchitecture}");
+ WriteLine($"{nameof(Environment.ProcessorCount)}: {Environment.ProcessorCount}");
+ WriteLine();
+
+ if(RuntimeInformation.OSDescription.StartsWith("Linux") && Directory.Exists("/sys/fs/cgroup"))
+ {
+ WriteLine("**CGroup info**");
+ WriteLine($"cfs_quota_us: {System.IO.File.ReadAllLines("/sys/fs/cgroup/cpu/cpu.cfs_quota_us")[0]}");
+ WriteLine($"memory.limit_in_bytes: {System.IO.File.ReadAllLines("/sys/fs/cgroup/memory/memory.limit_in_bytes")[0]}");
+ WriteLine($"memory.usage_in_bytes: {System.IO.File.ReadAllLines("/sys/fs/cgroup/memory/memory.usage_in_bytes")[0]}");
+
+ }
+ }
+ }
+}
diff --git a/samples/versioninfo/README.md b/samples/versioninfo/README.md
new file mode 100644
index 00000000..56e6bcb9
--- /dev/null
+++ b/samples/versioninfo/README.md
@@ -0,0 +1,28 @@
+# dotnet-versioninfo tool
+
+Produces information about your .NET, OS and hardware environment. It is also a demonstration of the APIs you can use to get this information for your own uses. This information is likely useful for logging.
+
+## Installation
+
+```console
+dotnet install -g dotnet-versioninfo
+```
+
+[dotnet-versioninfo package](https://www.nuget.org/packages/dotnetsay/)
+
+## Usage
+
+```console
+dotnet-versioninfo
+**.NET Core information
+Version: 3.1.7
+FrameworkDescription: .NET Core 3.1.7
+Libraries version: 3.1.7-servicing.20366.2
+Libraries hash: e8b17841cb5ce923aec48a1b0c12042d445d508f
+
+**Environment information
+OSDescription: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64
+OSVersion: Unix 19.6.0.0
+OSArchitecture: X64
+ProcessorCount: 8
+```
diff --git a/samples/versioninfo/versioninfo.csproj b/samples/versioninfo/versioninfo.csproj
new file mode 100644
index 00000000..03393052
--- /dev/null
+++ b/samples/versioninfo/versioninfo.csproj
@@ -0,0 +1,21 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+ <PropertyGroup>
+ <AssemblyName>dotnet-versioninfo</AssemblyName>
+ <Description>Displays .NET version and environment information.</Description>
+ <OutputType>Exe</OutputType>
+ <TargetFramework>netcoreapp3.1</TargetFramework>
+ <RollForward>LatestMajor</RollForward>
+ <VersionPrefix>1.0.0</VersionPrefix>
+ <Authors>.NET Team</Authors>
+ <License>MIT</License>
+ <PublishRepositoryUrl>true</PublishRepositoryUrl>
+ <DebugType>embedded</DebugType>
+ <PackAsTool>true</PackAsTool>
+ </PropertyGroup>
+
+ <ItemGroup Condition="'$(ContinuousIntegrationBuild)'=='true'">
+ <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
+ </ItemGroup>
+
+</Project>