Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add verison number before deployment or push or when file changes in visual studio

How to add version number dynamically to the end of the bundle URLs.

For example:

My bundle url: ~/Bundle/style.min.css?v=123

I wonder, how to dynamically change or add version number before deployment or push or when style.min.css changes.

Is it possible or not?

like image 853
Tolga Kısaoğulları Avatar asked Sep 19 '25 16:09

Tolga Kısaoğulları


1 Answers

I'm search around and find this article.

Based on it, in your BundleConfig you can redefine Styles.DefaultTagFormat and Scripts.DefaultTagFormat.

So if you need to change version on every build of application you can do this in RegisterBundles method:

var assemblyVersion = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
Styles.DefaultTagFormat = "<link href='{0}?v=" + assemblyVersion + "' rel='stylesheet'/>";
Scripts.DefaultTagFormat = "<script src='{0}?v=" + assemblyVersion + "'></script>";

Of course you can get version from your Config.

like image 51
teo van kot Avatar answered Sep 22 '25 07:09

teo van kot