获取或读取 asp.net 中使用章鱼部署的应用程序的版本

Get or read version in asp.net for application deployed with octopus

我正在使用 TeamCity 和 Octopus Deploy 来部署一个 Asp.Net 应用程序

我想显示部署应用程序时使用的版本号

在 teamcity 中,我使用 vcs 编号生成版本号

如何从 asp.net 中读取该信息或如何保存它以供日后检索?

版本标记在您的库中(只要您在构建它们之前设置版本号)。

这个版本号可以在运行时访问:

string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();

你也可以use the assembly version number in Octopus Deploy。这适用于 Team City、VSTS 等。这意味着 Octopus、Team City 和应用程序本身中显示的版本都将匹配,您将避免混淆。