Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tom 711 posts 948 karma points
    Aug 09, 2019 @ 05:42
    Tom
    0

    MORTEN!! - Umbraco 8 - Console App - CoreBootManager - UmbracoApplicationBase

    Hi all! (Especially Morten who wrote one of the first examples of a console app with Umbraco for v6 and v7)

    We wrote a console app which runs fluent migrator to migrate content, doc types properties etc for umbraco in v7 I'm porting it to v8 and would appreciate some help on understanding what has replaced corebootmanager and kicking the app off.

    This is the v7 code and in particular working out how to boostrap the console app

    /// <summary>
    /// Extends the CoreBootManager for use in this Console app.
    /// </summary>
    public class ConsoleBootManager : CoreBootManager
    {
        public ConsoleBootManager(UmbracoApplicationBase umbracoApplication, string baseDirectory)
            : base(umbracoApplication)
        {
            //This is only here to ensure references to the assemblies needed for the DataTypesResolver
            //otherwise they won't be loaded into the AppDomain.
    

    // Migration originally targeted a previous version of Umbraco so obosolete var interfacesAssemblyName = typeof(IDataType).Assembly.FullName; // Type or member is obsolete var editorControlsAssemblyName = typeof(uploadField).Assembly.FullName;

            base.InitializeApplicationRootPath(baseDirectory);
        }
    
        /// <summary>
        /// Can be used to initialize our own Application Events
        /// </summary>
        protected override void InitializeApplicationEventsResolver()
        {
            base.InitializeApplicationEventsResolver();
        }
    
        /// <summary>
        /// Can be used to add custom resolvers or overwrite existing resolvers once they are made public
        /// </summary>
        protected override void InitializeResolvers()
        {
            base.InitializeResolvers();
        }
    }
    
  • Shimi 2 posts 22 karma points
    Sep 19, 2019 @ 10:13
    Shimi
    0

    Hi, I am trying to create console application with umbraco 8. until now i don't understand how to do this.

    please some help :)

    thanks

  • Falco Prescher 2 posts 73 karma points
    Oct 09, 2019 @ 08:06
    Falco Prescher
    0

    As far as I researched creating a console application to do some one-time data processing does not work anymore. Or there is no documentation for it available yet.

    Instead I've used the following to hook into Umbraco V8 Web application to execute my migration code including access to the Umbraco API:

    Umbraco Documentation about Composing & Registering Components

    Here is my example code for importing some Wordpress posts by using the above concept:

    using Umbraco.Core.Composing;
    
    
    /// <summary>
    /// Registeres component in Umbraco automatically
    /// Starts import of some WordPress posts
    /// </summary>
    public class MyComposer : ComponentComposer<MyComponent>
    {
    }
    
    public class MyComponent : IComponent
    {
        // Initialize: runs once when Umbraco starts
        public void Initialize()
        {
            var contentService = Current.Services.ContentService;
            var logger = Current.Logger;
            var sqlContext = Current.SqlContext;
            var contentGridConverter = new ContentGridConverter();
            var wordpressArticleWpContentReplacer = new WordpressArticleWpContentReplacer();
            var myImporter = new myImporter(contentService, logger, contentGridConverter, wordpressArticleWpContentReplacer, sqlContext);
            myImporter.Import();
        }
    
        // Terminate: runs once when Umbraco stops
        public void Terminate()
        {
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft