简体   繁体   English

blazor wasm 应用程序运行时的程序集构建版本

[英]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.

相关问题 列出所有与 Blazor WASM 应用程序相关的程序集 - List all Assembly related a Blazor WASM application VS2022 版本 17.4.1 中未命中断点 blazor WASM 应用程序 DotNet6 - Breakpoints not hit in VS2022 Version 17.4.1 blazor WASM app DotNet6 在 .NET6 Blazor Webassembly 应用程序中使用外部程序集构建错误 - Build Error with External Assembly in .NET6 Blazor Webassembly App Blazor WASM 应用程序中的 Object 参考未设置错误 - Object reference not set error in Blazor WASM app Blazor WASM 应用程序未正确解释角色 - Roles not being interpreted correctly by Blazor WASM app Blazor proj 从头开始 + nuget:“没有可用于指定 RuntimeIdentifier 'browser-wasm' 的 Microsoft.AspNetCore.App 运行时包” - Blazor proj from scratch+nuget: "There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'browser-wasm'" 即使程序集版本更改,也可以构建/部署可与程序集一起使用的应用 - Build / deploy an app that works with an assembly even when the assembly version changes SynchronizationLockException: 无法在此运行时上等待监视器。 - Blazor wasm 中 TaskCompletionSource 的解决方法 - SynchronizationLockException: Cannot wait on monitors on this runtime. - Workaround for TaskCompletionSource in Blazor wasm 无法在 BuildRenderTree Blazor WASM 中使用构建 function - Cannot use build function inside BuildRenderTree Blazor WASM Null 检查破坏了我的 Blazor wasm web 应用程序的 UI - Null checks ruin the UI of my Blazor wasm web app
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM