/// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { // Register the runtime services Log.RegisterListener(new ConsoleTraceListener()); LifetimeManager.RegisterSingleton <IFileSystem, RuntimeFileSystem>(); this.InitializeComponent(); }
public BuildTask(IBuildState buildState, IValueFactory factory, Dictionary <string, Func <IValueTable, ICompiler> > compilerFactory) { this.buildState = buildState; this.factory = factory; this.compilerFactory = compilerFactory; // TODO: Not ideal to be registering this on the fly... if (!LifetimeManager.Has <IProcessManager>()) { LifetimeManager.RegisterSingleton <IProcessManager, RuntimeProcessManager>(); } }
public static async Task <int> Main(string[] args) { try { var traceFlags = TraceEventFlag.Information | TraceEventFlag.HighPriority | TraceEventFlag.Critical | TraceEventFlag.Warning | TraceEventFlag.Error; Log.RegisterListener(new ConsoleTraceListener("", new EventTypeFilter(traceFlags), false, false)); LifetimeManager.RegisterSingleton <IFileSystem, RuntimeFileSystem>(); if (args.Length < 2) { PrintUsage(); return(-1); } var command = args[0]; var workingDirectory = new Path(args[1]); switch (command) { case "restore-packages": { if (args.Length != 2) { PrintUsage(); return(-1); } await PackageManager.RestorePackagesAsync(workingDirectory); } break; case "install-package": { if (args.Length != 3) { PrintUsage(); return(-1); } var packageReference = args[2]; await PackageManager.InstallPackageReferenceAsync(workingDirectory, packageReference); } break; case "publish-package": { if (args.Length != 2) { PrintUsage(); return(-1); } await PackageManager.PublishPackageAsync(workingDirectory); } break; default: PrintUsage(); return(-1); } return(0); } catch (HandledException) { return(-1); } catch (Exception ex) { Log.HighPriority($"Unhandled Error: {ex}"); return(-2); } }
/// <summary> /// Initializes a new instance of the <see cref='ScopedSingleton{TInterface}'/> class. /// </summary> /// <param name="listener">The listener.</param> public ScopedSingleton(TInterface listener) { LifetimeManager.RegisterSingleton(listener); }
public static async Task <int> Main(string[] args) { try { var traceFlags = TraceEventFlag.Information | TraceEventFlag.HighPriority | TraceEventFlag.Critical | TraceEventFlag.Warning | TraceEventFlag.Error; Log.RegisterListener(new ConsoleTraceListener("", new EventTypeFilter(traceFlags), false, false)); LifetimeManager.RegisterSingleton <IFileSystem, RuntimeFileSystem>(); LifetimeManager.RegisterSingleton <IProcessManager, RuntimeProcessManager>(); if (args.Length != 0) { PrintUsage(); return(-1); } // Load up the Local User Config var localUserConfigPath = LifetimeManager.Get <IFileSystem>().GetUserProfileDirectory() + new Path(".soup/LocalUserConfig.toml"); var(loadConfigResult, userConfig) = await LocalUserConfigExtensions.TryLoadLocalUserConfigFromFileAsync(localUserConfigPath); if (!loadConfigResult) { Log.Info("No existing local user config."); } // Find the Roslyn SDKs var roslynInstallPath = await VSWhereUtilities.FindRoslynInstallAsync(); var roslynSDK = userConfig.EnsureSDK("Roslyn"); roslynSDK.SourceDirectories = new List <Path>() { roslynInstallPath, }; roslynSDK.SetProperties( new Dictionary <string, string>() { { "ToolsRoot", roslynInstallPath.ToString() }, }); var dotnetSDKInstallPath = new Path("C:/Program Files/dotnet/"); var dotnetSDK = userConfig.EnsureSDK("DotNet"); dotnetSDK.SourceDirectories = new List <Path>() { dotnetSDKInstallPath, }; dotnetSDK.SetProperties( new Dictionary <string, string>() { }); var(msvcVersion, msvcInstallPath) = await VSWhereUtilities.FindMSVCInstallAsync(); var msvcSDK = userConfig.EnsureSDK("MSVC"); msvcSDK.SourceDirectories = new List <Path>() { msvcInstallPath, }; msvcSDK.SetProperties( new Dictionary <string, string>() { { "Version", msvcVersion }, { "VCToolsRoot", msvcInstallPath.ToString() }, }); var(windowsSDKVersion, windowsSDKInstallPath) = WindowsSDKUtilities.FindWindows10Kit(); var windowsSDK = userConfig.EnsureSDK("Windows"); windowsSDK.SourceDirectories = new List <Path>() { windowsSDKInstallPath, }; windowsSDK.SetProperties( new Dictionary <string, string>() { { "Version", windowsSDKVersion }, { "RootPath", windowsSDKInstallPath.ToString() }, }); var netFXToolsPath = WindowsSDKUtilities.FindNetFXTools(); var netFXToolsSDK = userConfig.EnsureSDK("NetFXTools"); netFXToolsSDK.SourceDirectories = new List <Path>() { netFXToolsPath, }; netFXToolsSDK.SetProperties( new Dictionary <string, string>() { { "ToolsRoot", netFXToolsPath.ToString() }, }); // Save the result await LocalUserConfigExtensions.SaveToFileAsync(localUserConfigPath, userConfig); return(0); } catch (HandledException) { return(-1); } catch (Exception ex) { Log.HighPriority($"Unhandled Error: {ex}"); return(-2); } }