编程方式更改的AssemblyVersion和AssemblyF

编程方式更改的AssemblyVersion和AssemblyF

本文介绍了以编程方式更改的AssemblyVersion和AssemblyFileVersion属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个安装程序创建过程中,我计划做如下(在一个 C#脚本):

During a setup creation process, I am planning to do the following (within a C# Script):

  1. 阅读的AssemblyVersion AssemblyFileVersion 属性通过一个DLL的值。
  2. 迭代项目中的所有DLL文件和可执行文件,并应用这些版本的的AssemblyVersion AssemblyFileVersion 属性值。
  1. Read the AssemblyVersion and AssemblyFileVersion attribute values of one DLL.
  2. Iterate all DLLs and executables in the project and apply those version to their AssemblyVersion and AssemblyFileVersion attribute values.

现在的问题是:如何做第2步

我能够成功地执行步骤1,但对于第2步我没​​有看到一个真正的起点。我可能要做的是使用一些本地的P / Invoke方法,因为属性直接修改DLL /可执行文件的版本信息资源的信息。

I successfully can do step 1, but for step 2 I don't see a real start point. What I probably have to do is to use some native P/Invoke methods since the attributes directly modify the version information resource information of a DLL/executable.

在这个任何提示?

谢谢,乌韦

推荐答案

你为什么不,在构建过程中,阅读的AssemblyVersion AssemblyFileVersion 通过一个DLL,并保存回其他csproject的的AssemblyInfo.cs ,只有编译它?

Why don't you, during build process, read the AssemblyVersion and AssemblyFileVersion of one DLL, and save it back to other csproject's AssemblyInfo.cs, only then compile it?

由于事实上,我不知道是否有可能直接修改DLL文件,而不是诉诸什么稀奇的。

As a matter of fact, I don't know whether it is possible to modify the DLL file directly, without resorting to something fanciful.

或者,确保所有的DLL都有一个共同的的AssemblyInfo.cs 。您可以通过添加做到这一点的的AssemblyInfo.cs 为添加链接,当您在csproject添加新项目。在当你做一个编译这样一来,所有的DLL将共享相同的的AssemblyInfo.cs ,从而输出相同的的AssemblyVersion

Or alternatively, make sure that all your DLLs share one common AssemblyInfo.cs. You can do this by adding the AssemblyInfo.cs as "Add As Link" when you add a new item in csproject. In this way when you do a compilation, all the DLLs will share the same AssemblyInfo.cs, and thus output the same AssemblyVersion.

这篇关于以编程方式更改的AssemblyVersion和AssemblyFileVersion属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 19:55