如何更改 Visual Studio 中所有文件的版本

SLE*_*LEO 7 c# version assemblyinfo visual-studio

我在 Visual Studio 中有一个解决方案,它有许多项目和 DLL 文件,如何在构建之前或之后更改解决方案中所有文件(dll 和 exe 文件)的版本?

[解决方案信息

[装配信息

Vis*_*abu 5

可以通过编辑 Assemblyinfo.cs 文件来更改程序集信息,该文件可以在解决方案资源管理器中的项目属性下看到,在这里您可以更改程序集的版本

\n\n
using System.Reflection;\nusing System.Runtime.CompilerServices;\nusing System.Runtime.InteropServices;\n\n// General Information about an assembly is controlled through the following \n// set of attributes. Change these attribute values to modify the information\n// associated with an assembly.\n[assembly: AssemblyTitle("My App Title")]\n[assembly: AssemblyDescription("App Description")]\n[assembly: AssemblyCompany("My Company Name")]\n[assembly: AssemblyProduct("ConsoleApp")]\n[assembly: AssemblyCopyright("Copyright \xc2\xa9 2015")]\n[assembly: AssemblyTrademark("My Company Trademark")]\n[assembly: AssemblyCulture("")]\n\n// Setting ComVisible to false makes the types in this assembly not visible \n// to COM components.  If you need to access a type in this assembly from \n// COM, set the ComVisible attribute to true on that type.\n[assembly: ComVisible(false)]\n\n// The following GUID is for the ID of the typelib if this project is exposed to COM\n[assembly: Guid("513436d3-aa2f-407b-83d2-9268300cc373")]\n\n// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Build and Revision Numbers \n\n//*******Assembly Version can be changed here*********\n// by using the \'*\' as shown below:\n// [assembly: AssemblyVersion("1.0.*")]\n[assembly: AssemblyVersion("1.0.0.0")]\n[assembly: AssemblyFileVersion("1.0.0.0")]\n
Run Code Online (Sandbox Code Playgroud)\n\n

或者

\n\n
    \n
  • 转到解决方案资源管理器
  • \n
  • 右键单击您的项目
  • \n
  • 选择属性
  • \n
  • 在出现的窗口中单击程序集信息
  • \n
  • 在弹出框中您可以编辑装配相关的详细信息
  • \n
  • 单击“确定”,您的 AssemblyInfo.cs 文件就会自动更新\n

    \n\n

    弹出框,您可以在其中编辑装配体相关详细信息

  • \n
\n


Kri*_*ner 1

正如评论中AssemblyInfo.cs指出的那样,如果您要更改:

\n\n
// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Revision and Build Numbers \n// by using the \'*\' as shown below:\n[assembly: AssemblyVersion("1.0.0.0")]\n[assembly: AssemblyFileVersion("1.0.0.0")]\n
Run Code Online (Sandbox Code Playgroud)\n\n

到:

\n\n
// Version information for an assembly consists of the following four values:\n//\n//      Major Version\n//      Minor Version \n//      Build Number\n//      Revision\n//\n// You can specify all the values or you can default the Revision and Build Numbers \n// by using the \'*\' as shown below:\n[assembly: AssemblyVersion("1.0.*")]\n
Run Code Online (Sandbox Code Playgroud)\n\n

每次构建后,程序集将获得新的构建号/修订版。

\n\n

来自MSDN

\n\n
\n

您可以指定所有值,也可以使用星号 ( ) 接受默认内部版本号、修订号或两者。例如,[ assembly:AssemblyVersion("2.3.25.1")] 表示 2 为主版本,3 为次版本,25 为内部版本号,1 为修订号。版本号(例如 [ assembly:AssemblyVersion("1.2. ")] 指定 1 作为主要版本,2 作为次要版本,并接受默认的内部版本号和修订号。版本号(例如 [程序集:AssemblyVersion(“1.2.15.*”)] 指定 1 作为主要版本,2 作为次要版本,15 作为内部版本号,并接受默认修订号。默认内部版本号每日递增。默认修订号是自当地时间午夜以来的秒数(不考虑夏令时的时区调整)除以 2。

\n
\n\n

共享程序集信息教程:

\n\n

http://theburningmonk.com/2010/03/net-tips-use-a-shared- assemblyinfo-cs-for-your-solution/

\n\n
    \n
  1. cre\xc2\xadate 在解决方案\xe2\x80\x99s 根目录下的 SharedAssemblyInfo.cs 文件,然后将所有常用设置放在那里。
  2. \n
  3. 右键单击您的项目并添加现有项\xe2\x80\xa6,浏览到 SharedAssemblyInfo.cs,并确保选择“添加为链接”。
  4. \n
\n