[英]Assembly build version at runtime in blazor wasm app
What is the best way to get build version number at runtime in web assembly client-side blazor app?在运行时在 web 程序集客户端 blazor 应用程序中获取构建版本号的最佳方法是什么? In server side version I was able to use
Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.ToString();
在服务器端版本中,我能够使用
Assembly.GetEntryAssembly().GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion.ToString();
Combined with msbump package it was automatically generating new version for me with each new build.结合 msbump package,它会在每次新构建时自动为我生成新版本。 Is that possible to achieve at client side blazor too?
这也可以在客户端 blazor 实现吗?
try using GetExecutingAssembly()
.尝试使用
GetExecutingAssembly()
。
Example:例子:
Assembly.GetExecutingAssembly().
GetCustomAttribute<AssemblyInformationalVersionAttribute>().
InformationalVersion;
The reason you can't use the entry assembly is I believe the entry assembly is not your actual assembly.您不能使用入口程序集的原因是我相信入口程序集不是您的实际程序集。 So if you call out for executing assembly you are guaranteed to get your actual assembly.
因此,如果您要求执行程序集,则可以保证获得实际的程序集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.