Neat bundling solution

4 posts, 0 answers
  1. Andrew
    Andrew avatar
    29 posts
    Member since:
    Jul 2010

    Posted 06 Dec 2016 Link to this post

    I've long thought the pattern for bundling files, that included the version number was ugly, and was a barrier to quick upgrade of Kendo versions. Now that we have a private nuget, I wanted to make upgrading versions easier.

     

    As an idea I came up with the following : this removes all version constants from the bundling and layout. It would be nice if there was a static Version getter on the Kendo class though :-) Kendo.Version would make it much clearer (hint!)

     

        //BundleConfig.cs
            var version = typeof(Kendo.Mvc.UrlGenerator).Assembly.GetName().Version;
            var kendoVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
     
     
            bundles.Add(new StyleBundle("~/Content/kendo/"+kendoVersion+"/css").Include(
                "~/Content/kendo/"+kendoVersion+"/kendo.common.min.css",
                "~/Content/kendo/"+kendoVersion+"/kendo.default.min.css"
                ));
     
            bundles.Add(new ScriptBundle("~/Scripts/kendo/" +  kendoVersion +"/scripts").Include(
                "~/Scripts/kendo/" + kendoVersion + "/kendo.all.min.js",
                "~/Scripts/kendo/" + kendoVersion + "/kendo.aspnetmvc.min.js",
                "~/Scripts/kendo/" + kendoVersion + "/cultures/kendo.culture.en-GB.min.js"
                ));
     
     
        //_Layout.cshtml
    @{
        var version = typeof(Kendo.Mvc.UrlGenerator).Assembly.GetName().Version;
        var kendoVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
    }
     
     
    @Styles.Render("~/Content/kendo/" + kendoVersion + "/css")
    /* ... */
    @Scripts.Render("~/Scripts/kendo/" +  kendoVersion +"/scripts")
  2. Angel Petrov
    Admin
    Angel Petrov avatar
    1044 posts

    Posted 08 Dec 2016 Link to this post

    Hi,

    Thank you for sharing the solution with the community. I hope that it will help others make the upgrading process smoother.

    As for implementing a version getter I suggest logging a feature request in our feedback portal.

    Regards,
    Angel Petrov
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
  3. Andrew
    Andrew avatar
    29 posts
    Member since:
    Jul 2010

    Posted 08 Dec 2016 in reply to Angel Petrov Link to this post

    Feature request added.

    Would you consider updating the documentation to reflect this pattern (or one with the Kendo.Version if it gets added) as I think it greatly simplifies things?

  4. Angel Petrov
    Admin
    Angel Petrov avatar
    1044 posts

    Posted 12 Dec 2016 Link to this post

    Hello,

    I've forwarded this idea to our Documentation team. They will take over the case from here. As a token of gratitude, I've updated your account points.

    Regards,
    Angel Petrov
    Telerik by Progress
    Telerik UI for ASP.NET MVC is ready for Visual Studio 2017 RC! Learn more.
Back to Top