dotnet-installer/TestAssets/TestPackages/dotnet-portable/Program.cs

32 lines
1.1 KiB
C#
Raw Normal View History

// 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.
using System;
using System.IO;
using System.Reflection;
2016-03-17 18:43:01 +00:00
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello Portable World!");
2017-04-26 21:57:18 +00:00
var depsFile = new FileInfo(GetDataFromAppDomain("FX_DEPS_FILE"));
string frameworkVersion = depsFile.Directory.Name;
Console.WriteLine($"I'm running on shared framework version {frameworkVersion}!");
2016-03-17 18:43:01 +00:00
}
2017-04-26 21:57:18 +00:00
public static string GetDataFromAppDomain(string propertyName)
{
var appDomainType = typeof(object).GetTypeInfo().Assembly?.GetType("System.AppDomain");
var currentDomain = appDomainType?.GetProperty("CurrentDomain")?.GetValue(null);
var deps = appDomainType?.GetMethod("GetData")?.Invoke(currentDomain, new[] { propertyName });
return deps as string;
}
2016-03-17 18:43:01 +00:00
}
}