简体   繁体   English

设置AssemblyInfo.cs的默认值

[英]Setting the default values of AssemblyInfo.cs

What is the best way to change the default values that AssemblyInfo.cs is created with, eg I don't want the Microsoft bits in AssemblyCompany and AssemblyCopyright 更改AssemblyInfo.cs创建的默认值的最佳方法是什么,例如我不希望AssemblyCompany和AssemblyCopyright中的Microsoft位

[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2011")]

It appears that this info is embedded in the project template definition. 看来这个信息嵌入在项目模板定义中。 For instance, if I create a project using the "Console Application" project template, it uses: 例如,如果我使用“控制台应用程序”项目模板创建项目,它使用:

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033\ConsoleApplication.zip

Looking inside that zip file there is an AssemblyInfo.cs file which contains: 查看该zip文件,有一个AssemblyInfo.cs文件,其中包含:

[assembly: AssemblyCompany("$registeredorganization$")]
[assembly: AssemblyProduct("$projectname$")]
[assembly: AssemblyCopyright("Copyright © $registeredorganization$ $year$")]

So if you can't change the registration info of your machine like others have suggested, you could just update this file here 因此,如果您无法像其他人建议的那样更改机器的注册信息,则可以在此处更新此文件

Probably only in registry: 可能只在注册表中:

32 bit: HKLM\Software\Microsoft\Windows NT\CurrentVersion
64 bit: HKLM\Software\Wow6432Node\Microsoft\WindowsNT\CurrentVersion

Changing the default values for AssemblyInfo.cs 更改AssemblyInfo.cs的默认值

Also here is the post on SO: How to change registration company name for Visual Studio 2008? 另外这里是关于SO的帖子: 如何更改Visual Studio 2008的注册公司名称?

Little offtopic: Every project has its own assemblyinfo.cs. 很少的offtopic:每个项目都有自己的assemblyinfo.cs。 To keep things DRY, I'd recommend the usage of a GlobalAssemblyInfo 为了保持干燥,我建议使用GlobalAssemblyInfo

As an update, I found this location and updated all the assemblyinfo.cs files for the various project types (Visual Studio 2015, Windows 10). 作为更新,我找到了这个位置并更新了各种项目类型的所有assemblyinfo.cs文件(Visual Studio 2015,Windows 10)。 That seems to have worked: 这似乎有效:

C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\ProjectTemplates\\CSharp\\Windows Root\\Windows\\1033 C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE \\ ProjectTemplates \\ CSharp \\ Windows Root \\ Windows \\ 1033

If you mean when you create a new VS Project it should default to your firm name, you can modify the project templates but this will need to be done on each dev machine. 如果您的意思是在创建新的VS项目时它应该默认为您的公司名称,您可以修改项目模板,但这需要在每台开发机器上完成。

If you're trying to alleviate the PITA of managing this common data in all of the assemblies in a solution you could use a SharedAssemblyInfo.cs file. 如果您正在尝试减轻PITA在解决方案中的所有程序集中管理此公共数据,则可以使用SharedAssemblyInfo.cs文件。 Create this at the solution level then add to all of your other projects by adding it as a linked file (the Add Dialog box has a little flyout on the button). 在解决方案级别创建此项,然后通过将其添加为链接文件添加到所有其他项目(“添加”对话框在按钮上有一个小弹出按钮)。 This approach is used commonly for assembly versioning 此方法通常用于程序集版本控制

More info from this SO post also. 来自此SO帖子的更多信息也。

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

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