public void Execute()
        {
            try
            {
                InitializeEnvironment();

                // Read config
                var configuration = new Configuration(Config);

                // Set up the basics
                var msCoreReferenceFinder = new MsCoreReferenceFinder(this, ModuleDefinition.AssemblyResolver);
                msCoreReferenceFinder.Execute();

                // Create method that imports the types
                var loadTypesWeaver = new LoadTypesWeaver(ModuleDefinition, msCoreReferenceFinder, configuration, this);
                var loadTypesMethod = loadTypesWeaver.Execute();

                // Call method on assembly init
                var moduleLoaderImporter = new ModuleLoaderImporter();
                moduleLoaderImporter.ImportModuleLoader(ModuleDefinition, loadTypesMethod, msCoreReferenceFinder);
            }
            catch (Exception ex)
            {
                LogError(ex.Message);

#if DEBUG
                Debugger.Launch();
#endif
            }
        }
Exemple #2
0
        public override void Execute()
        {
            try
            {
#if DEBUG
                if (!Debugger.IsAttached)
                {
                    Debugger.Launch();

                    //FodyEnvironment.LogDebug = CreateLoggingCallback(LogDebug);
                    //FodyEnvironment.LogInfo = CreateLoggingCallback(LogInfo);
                    //FodyEnvironment.LogWarning = CreateLoggingCallback(LogWarning);
                    //FodyEnvironment.LogError = CreateLoggingCallback(LogError);
                }
#endif

                // First of all, set the assembly resolver
                if (AssemblyResolver == null)
                {
                    AssemblyResolver = ModuleDefinition.AssemblyResolver;
                }

                // Clear cache because static members will be re-used over multiple builds over multiple systems
                CacheHelper.ClearAllCaches();

                InitializeEnvironment();

                // Read config
                var configuration = new Configuration(Config);

                LogInfo($"LoadAssembliesOnStartup.Fody v{GetType().Assembly.GetName().Version}");

                // Set up the basics
                var msCoreReferenceFinder = new MsCoreReferenceFinder(this, ModuleDefinition.AssemblyResolver);
                msCoreReferenceFinder.Execute();

                // Create method that imports the types
                var loadTypesWeaver = new LoadTypesWeaver(ModuleDefinition, msCoreReferenceFinder, configuration, this);
                var loadTypesMethod = loadTypesWeaver.Execute();

                // Call method on assembly init
                var moduleLoaderImporter = new ModuleLoaderImporter();
                moduleLoaderImporter.ImportModuleLoader(ModuleDefinition, loadTypesMethod, msCoreReferenceFinder);
            }
            catch (Exception ex)
            {
                LogError(ex.Message);

#if DEBUG
                Debugger.Launch();
#endif
            }
        }