dotnet-installer/TestAssets/TestPackages/dotnet-portable/Program.cs
2017-04-27 09:30:40 -07:00

31 lines
1.1 KiB
C#

// 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;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello Portable World!");
var depsFile = new FileInfo(GetDataFromAppDomain("FX_DEPS_FILE"));
string frameworkVersion = depsFile.Directory.Name;
Console.WriteLine($"I'm running on shared framework version {frameworkVersion}!");
}
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;
}
}
}