简体   繁体   English

如何使用c#或msbuild显示当前版本?

[英]how to show the current build with c# or msbuild?

I created an asp.net mvc4 application and I have setup continuous integration and deployment to windows azure. 我创建了一个asp.net mvc4应用程序,并设置了持续集成并将其部署到Windows Azure。

Because I have configured it to build after checkin, it would be very useful to print somewhere in the application which build is using. 因为我已将其配置为在签入之后构建,所以在构建所使用的应用程序中的某处打印将非常有用。

I guess there should be a way with c# and msbuild api if it exists, which is the current build. 我想应该有一种使用c#和msbuild api的方法(如果存在的话),这是当前的版本。

something like: FullStackSampleApplication_20130413.2 类似于:FullStackSampleApplication_20130413.2

Any guidance would be really appreciated. 任何指导将不胜感激。

I found this line: 我发现这条线:

Update1: I added this to AssemblyInfo.cs Update1:我将此添加到AssemblyInfo.cs

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

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

This line is printing 0.0.0.0 该行正在打印0.0.0.0

To generate new build number and revision on each build, add to your AssemblyInfo.cs 要在每个内部版本上生成新的内部版本号和修订版,请添加到您的AssemblyInfo.cs中

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

The generated numbers will be based on build time. 生成的数字将基于构建时间。 Build number will be the number of days since 2000, and revision number will be the number of seconds since midnight/2. 内部版本号将是自2000年以来的天数,而修订版号将是自午夜/ 2以来的秒数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM