以前在RC.x中工作的内容都不再有用。在ASP.NET Core 1.0.0 web应用程序中显示项目版本
我尝试了这些:
PlatformServices.Default.Application.ApplicationVersion;
typeof(Controller).GetTypeInfo()。Assembly.GetCustomAttribute <AssemblyFileVersionAttribute>().Version;
- Assembly.GetEntryAssembly()。GetName()。Version.ToString();
他们都返回1.0.0.0代替1.0.0-9这应该是在project.json: "version": "1.0.0-*"
基本上有这个dotnet publish --version-suffix 9
执行后,他们给我的“文件版本”从附加的图片,而不是“产品版本“dotnet publish
实际上似乎改变了。
谢谢,这是非常有帮助的。为什么asp.net核心团队不支持1.0.0 *,而不是1- *超越了我。 Microsoft .NET程序集的版本号一直是int.int.int.int,从编程的角度来看是有意义的。在构建#中支持字符串不是必需的,会导致其他问题。 – evermeire
而是使用System.Reflection.IntrospectionExtensions.GetTypeInfo( typeof(ArmoredOutputStream) ) .Assembly.GetCustomAttribute()。Version; //注意:其中ArmoredOutputStream是您想要的版本的程序集中的类 –
编辑具有误导性,可能是由于编辑器的某些自定义设置。正确答案是Assembly.GetEntryAssembly()。GetCustomAttribute()。InformationalVersion FileVersion删除预发布标签 –