This is a migrated thread and some comments may be shown as answers.

Neat bundling solution

3 Answers 107 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 06 Dec 2016, 08:17 PM

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")

3 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 08 Dec 2016, 12:10 PM
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.
0
Andrew
Top achievements
Rank 1
answered on 08 Dec 2016, 12:55 PM

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?

0
Angel Petrov
Telerik team
answered on 12 Dec 2016, 07:53 AM
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.
Tags
General Discussions
Asked by
Andrew
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or