使用 Visual Studio 时可以自动增加文件构建版本吗? [英] Can I automatically increment the file build version when using Visual Studio?

查看:30
本文介绍了使用 Visual Studio 时可以自动增加文件构建版本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是想知道如何使用 Visual Studio (2005)自动增加文件的构建(和版本?).

I was just wondering how I could automatically increment the build (and version?) of my files using Visual Studio (2005).

如果我查找 C:Windows otepad.exe 的属性,版本选项卡会显示文件版本:5.1.2600.2180".我也想在我的 dll 版本中获得这些很酷的数字,而不是 1.0.0.0 版本,让我们面对它有点乏味.

If I look up the properties of say C:Windows otepad.exe, the Version tab gives "File version: 5.1.2600.2180". I would like to get these cool numbers in the version of my dll's too, not version 1.0.0.0, which let's face it is a bit dull.

我尝试了一些东西,但它似乎不是开箱即用的功能,或者我可能只是找错了地方(像往常一样).

I tried a few things, but it doesn't seem to be out-of-box functionality, or maybe I'm just looking in the wrong place (as usual).

我主要从事网络项目......

I work with mainly web projects....

我都看了:

  1. http://www.codeproject.com/KB/dotnet/Auto_Increment_Version.aspx
  2. http://www.codeproject.com/KB/dotnet/build_versioning.aspx

我简直不敢相信付出这么多努力是标准做法.

and I couldn't believe it so much effort to do something is standard practice.

据我所知,它在 VS2005 中不起作用(http://www.codeproject.com/KB/dotnet/AutoIncrementVersion.aspx)

推荐答案

在 Visual Studio 2008 中,以下工作.

In visual Studio 2008, the following works.

找到 AssemblyInfo.cs 文件并找到以下 2 行:

Find the AssemblyInfo.cs file and find these 2 lines:

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

您可以尝试将其更改为:

You could try changing this to:

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

但这不会给您想要的结果,您最终会得到 1.0.* 的产品版本和 1.0.0.0 的文件版本.不是你想要的!

But this won't give you the desired result, you will end up with a Product Version of 1.0.* and a File Version of 1.0.0.0. Not what you want!

但是,如果您删除这些行中的第二行,而只有:

However, if you remove the second of these lines and just have:

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

然后编译器会将文件版本设置为等于产品版本,您将获得您想要的自动递增同步的产品和文件版本的结果.例如.1.0.3266.92689

Then the compiler will set the File Version to be equal to the Product Version and you will get your desired result of an automatically increment product and file version which are in sync. E.g. 1.0.3266.92689

这篇关于使用 Visual Studio 时可以自动增加文件构建版本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆