C# 装配文件版本没有改变?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1158252/
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
Assembly File Version not changing?
提问by maxp
I have in my assemblyinfo.cs class the code:
我的 assemblyinfo.cs 类中有代码:
[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyFileVersion("1.0.*")]
Calling System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
works fine and gives the updated version, however, when i look at the generated dll in windows explorer, right click properties, click the 'details' tab, the fileversion says "1.0.0.0" even though the output above says 1.0.3489.17621 ?
调用System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()
工作正常并提供更新的版本,但是,当我在 Windows 资源管理器中查看生成的 dll 时,右键单击属性,单击“详细信息”选项卡,文件版本显示“1.0.0.0”,即使上面的输出显示为 1.0.3489.17621 ?
采纳答案by Patrick McDonald
You cannot use 1.0.* to auto-increment the AssemblyFileVersion, only the AssemblyVersion. (Checked in all Visual Studio versions from 2005 to 2012).
您不能使用 1.0.* 自动增加 AssemblyFileVersion,只能使用 AssemblyVersion。(检入 2005 年至 2012 年的所有 Visual Studio 版本)。
Comment out the following line
注释掉以下行
[assembly: AssemblyFileVersion("1.0.*")]
[程序集:AssemblyFileVersion("1.0.*")]
and the File Version will take the same number as the Assembly Version.
并且文件版本将采用与程序集版本相同的编号。
回答by Oliver
Patrick already gave the correct answer, but here is just a little advice. If you look into AssemblyInfo.cs you'll find the following block at the end:
帕特里克已经给出了正确的答案,但这里只是一点建议。如果您查看 AssemblyInfo.cs,您会在最后找到以下块:
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
//[assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
Now go on and flip the comment from the last three lines as follows:
现在继续翻转最后三行的注释,如下所示:
[assembly: AssemblyVersion("1.0.*")]
//[assembly: AssemblyVersion("1.0.0.0")]
//[assembly: AssemblyFileVersion("1.0.0.0")]
And everything works as expected... :-)
一切都按预期工作...... :-)