C# ASP.Net 版本/内部版本号

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1168279/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 09:52:08  来源:igfitidea点击:

ASP.Net Version/Build Number

c#.netasp.net

提问by MartGriff

I have a ASP.Net (.net 3.5/c#) and I want to display a version number / build number and date. What is the best way in controling this and is it possible to auto incriment the numbers on build?

我有一个 ASP.Net (.net 3.5/c#),我想显示一个版本号/内部版本号和日期。控制这种情况的最佳方法是什么,是否可以在构建时自动增加数字?

What is the standard for version numbers & build number?

版本号和内部版本号的标准是什么?

Im using VS 2008 how would I get the data and assign to a string value so I can show in the footer of the webpage?

我使用 VS 2008 如何获取数据并分配给一个字符串值,以便我可以在网页的页脚中显示?

采纳答案by Scott Ivey

If you're using a Web Application Project - you could do it like this...

如果您使用的是 Web 应用程序项目 - 您可以这样做...

Assembly web = Assembly.Load("App_Code");
AssemblyName webName = web.GetName();

string myVersion = webName.Version.ToString();

If you're using a Web Site project - nearly the same...

如果您使用的是网站项目 - 几乎相同...

Assembly web = Assembly.GetExecutingAssembly();
AssemblyName webName = web.GetName();

string myVersion = webName.Version.ToString();

回答by PaulG

You can set the first two parts of the version number, and leave a wildcard for the compiler to autocomplete the last two parts, by editing the GlobalAssemblyInfo.cslike so:

您可以设置版本号的前两部分,并为编译器保留通配符以自动完成后两部分,通过如下编辑GlobalAssemblyInfo.cs

[assembly:AssemblyFileVersion("1.0.*")]

It autocompletes the last two parts with a number of days since 1st Jan 2000, and the number of seconds since midnight. This may help with the second part of your query to display the date/time the version was built.

它使用自 2000 年 1 月 1 日以来的天数和自午夜以来的秒数自动完成最后两部分。这可能有助于查询的第二部分显示构建版本的日期/时间。