https://discord.umbraco.com logo
Join Discord
Channels
help-with-umbraco
news
event-news
social
help-with-other
contributing
package-development
codegarden-conference
hacktoberfest
show-and-tell
jobs-and-gigs
meta
Powered by
# package-development
  • c

    CodeSharePaul

    09/17/2021, 7:47 PM
    Ok so now i have it almost working. Just have an issue with the assets in the wwwroot. I have them in the package but not copying over when the package installs. Any ideas?
  • c

    CodeSharePaul

    09/17/2021, 7:51 PM
    I found an extra ..\ in my build targets file that might be it
  • c

    CodeSharePaul

    09/17/2021, 10:21 PM
    Yay I got it working https://our.umbraco.com/packages/starter-kits/portfolio-starter-kit/
  • k

    Kevin Jump

    09/20/2021, 6:20 PM
    appsettings.json schemas! - I have something working in principle, but i am not sure of the best way to do it - robustly.
  • k

    Kevin Jump

    09/20/2021, 6:21 PM
    Umbraco has its own schema at
    /umbraco/config/appsettings-schema.json
  • k

    Kevin Jump

    09/20/2021, 6:21 PM
    i know if i add an extra few lines to the "properties" section i can add uSync schemas..
  • k

    Kevin Jump

    09/20/2021, 6:22 PM
    e.g :
    Copy code
    "uSync": {   
      "$ref": "../../App_Plugins/uSync/config/appsettings-usync-schema.json#/definitions/uSync"    
    }
  • k

    Kevin Jump

    09/20/2021, 6:22 PM
    its not to complicated code wise, i have an .exe that will do it, and i can add it as a 'Exec' step to a task, so it happens at build 🎉
  • k

    Kevin Jump

    09/20/2021, 6:23 PM
    but not sure if that is right - seems hacky, so maybe a custom task ? - but they are super difficult to pull off in .net5 - mainly because dependent dll's don't get copied over with the task 😦
  • k

    Kevin Jump

    09/20/2021, 6:24 PM
    anyone? got any ideas on how to do this in a less hacky way ? or is this the 'right' way ?
  • s

    Sebastiaan

    09/20/2021, 6:32 PM
    I guess we just generated ours once, not sure. Maybe @Warren Buckley has some tips.
  • k

    Kevin Jump

    09/20/2021, 6:34 PM
    yeah - but you can't have multiple root schemas (i think) so package devs will have to piggy back on the Umbraco one - the process above 'injects' a file that has the uSync config schema into the umbraco file. - it "works" i think.
  • w

    Warren Buckley

    09/20/2021, 7:15 PM
    Yep your right you can't have multiple JSON schemas. So we hacked the planet for ours thats generated at every build as part of pipeline. But what it does is download the schemastore online JSON schema and we merge that with ours. Elegant: NOPE. Does it work: Sure does https://github.com/umbraco/Umbraco-CMS/tree/v9/dev/src/JsonSchema I am sure @User would be happy if you got any ideas on how we could make it extensible or help package developers life's easier to generate their settings.
  • w

    Warren Buckley

    09/20/2021, 7:22 PM
    An alternative thought could be that you have
    uSync.development.json
    and
    usync.production.json
    files that you add as additional files to load/read from Then those separate files can have their own JSON schema without worrying about ours. https://docs.microsoft.com/en-us/dotnet/core/extensions/configuration-providers#json-configuration-provider
  • k

    Kevin Jump

    09/20/2021, 7:47 PM
    Ok thought about that, but then got lost in some blog posts that kept telling me building the config was expensive and .net 6 was going to do something cleverer (but it was late I so my brain turned itself off)
  • k

    Kevin Jump

    09/20/2021, 7:50 PM
    Also not sure if that's possible in Umbraco without changing program.cs or startup.cs (i.e compose is to late?)
  • w

    Warren Buckley

    09/20/2021, 7:54 PM
    Hmm yeh would need to experiment if a composer could add to the config later on (Gut feeling is probably not)
  • r

    Richard Soeteman

    09/21/2021, 6:33 AM
    `You need to hack startup.cs indeed would not be ideal. Not sure if you can do the same but most of my packages use config where most is set to default. So I initialise the config with defaults and allow people to add a custom section to appsettings.json. for now..
  • s

    skttl

    09/21/2021, 6:39 AM
    Can't you tell the user to swap out the schema when needing intellisense for other than Umbraco? So you basically have more than on
    $schema
    in your json, but comment out "inactive" ones? like
    Copy code
    {
      "$schema": "https://json.schemastore.org/appsettings.json",
    //  "$schema": "https://usync.org/appsettings.json",
    //  "$schema": "https://doctypegrideditor.skttl.dk/appsettings.json",
  • s

    skttl

    09/21/2021, 6:41 AM
    and 2 seconds later, I remembered that JSON doesn't support comments
  • k

    Kevin Jump

    09/21/2021, 7:03 AM
    Yeah, it's all defaults so works with no config, but people always want to be different 😄
  • r

    Richard Soeteman

    09/21/2021, 7:04 AM
    True and then you can add it to appsettins.json
  • r

    Richard Soeteman

    09/21/2021, 7:05 AM
    Would be ideal if we could have separate json files. But I think the whole reason of startup.cs is that you can store config anywhere you want Azure etc..
  • k

    Kevin Jump

    09/21/2021, 7:08 AM
    Yeah I am all for settings in appsettings/where ever in the settings chain you want it. it's where umbraco settings are and people will expect it there . It's just surfacing the intellisense so it makes it easier. 🤔
  • w

    Warren Buckley

    09/21/2021, 10:25 AM
    I am gonna have at look at this at lunchtime https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/platform-specific-configuration?view=aspnetcore-5.0
  • w

    Warren Buckley

    09/21/2021, 12:00 PM
    So this works
    Copy code
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.Configuration;
    
    [assembly: HostingStartup(typeof(MyAwesomePackage.MyPackageConfig))]
    namespace MyAwesomePackage
    {
        public class MyPackageConfig : IHostingStartup
        {
            public void Configure(IWebHostBuilder builder)
            {
                builder.ConfigureAppConfiguration((ctx, config) =>
                {
                    var env = ctx.HostingEnvironment;
    
                    config.AddJsonFile("mypackage.json", optional: true, reloadOnChange: true)
                          .AddJsonFile($"mypackage.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
                });
            }
        }
    }
    But the problem is that .NET does not auto scan all assemblies. You have to use/update ENV variable
    "ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "MyAwesomePackage;"
    Still poking around but not sure setting an ENV variable gonna be much nicer/friendlier than what we have. Currently trying to see how/if other libraries use this approach
  • r

    Richard Soeteman

    09/21/2021, 1:23 PM
    How will be determined if a Nuget package supports a certain Umbraco version? By referencing an Umbraco package?
  • m

    Matt Wise

    09/21/2021, 1:24 PM
    If the package references Umbraco it will usually have a dependency set with a range
  • r

    Richard Soeteman

    09/21/2021, 1:30 PM
    Ok thanks but referencing v9+ Umbraco package is the way to tell Umbraco a package is made for v9?
  • s

    soren7885

    09/21/2021, 1:31 PM
    @User you should be able to see the dependencies
12345...58Latest