2016-03-03 22:57:43 -08:00
|
|
|
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
|
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
|
|
|
|
2016-04-18 15:51:35 -07:00
|
|
|
|
using System;
|
2016-03-03 22:57:43 -08:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
2016-09-22 18:34:24 -05:00
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
2016-08-05 16:54:41 -07:00
|
|
|
|
using Microsoft.DotNet.PlatformAbstractions;
|
2016-03-03 22:57:43 -08:00
|
|
|
|
|
2016-09-22 18:34:24 -05:00
|
|
|
|
namespace Microsoft.DotNet.Cli
|
2016-03-03 22:57:43 -08:00
|
|
|
|
{
|
2016-09-22 18:34:24 -05:00
|
|
|
|
internal static class DotnetFiles
|
2016-03-03 22:57:43 -08:00
|
|
|
|
{
|
2016-06-10 15:06:48 -07:00
|
|
|
|
private static string SdkRootFolder => Path.Combine(typeof(DotnetFiles).GetTypeInfo().Assembly.Location, "..");
|
|
|
|
|
|
2016-09-29 18:16:26 -05:00
|
|
|
|
private static Lazy<DotnetVersionFile> s_versionFileObject =
|
|
|
|
|
new Lazy<DotnetVersionFile>(() => new DotnetVersionFile(VersionFile));
|
|
|
|
|
|
2016-03-03 22:57:43 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The CLI ships with a .version file that stores the commit information and CLI version
|
|
|
|
|
/// </summary>
|
2016-06-10 15:06:48 -07:00
|
|
|
|
public static string VersionFile => Path.GetFullPath(Path.Combine(SdkRootFolder, ".version"));
|
2016-04-18 15:51:35 -07:00
|
|
|
|
|
2016-09-29 18:16:26 -05:00
|
|
|
|
internal static DotnetVersionFile VersionFileObject
|
|
|
|
|
{
|
|
|
|
|
get { return s_versionFileObject.Value; }
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-18 15:51:35 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reads the version file and adds runtime specific information
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string ReadAndInterpretVersionFile()
|
|
|
|
|
{
|
|
|
|
|
var content = File.ReadAllText(DotnetFiles.VersionFile);
|
|
|
|
|
content += Environment.NewLine;
|
2016-04-28 16:30:32 -07:00
|
|
|
|
content += RuntimeEnvironment.GetRuntimeIdentifier();
|
2016-04-18 15:51:35 -07:00
|
|
|
|
return content;
|
|
|
|
|
}
|
2016-03-03 22:57:43 -08:00
|
|
|
|
}
|
|
|
|
|
}
|