visual-studio 在 VS 2005 中重新生成丢失的 AssemblyInfo.cs

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/547962/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:09:36  来源:igfitidea点击:

Regenerate missing AssemblyInfo.cs in VS 2005

visual-studioassemblyinfo

提问by Andrew M

I'm trying to build a small VS 2005 solution I've just checked out of source control, and I'm getting this easy to understand error:

我正在尝试构建一个小的 VS 2005 解决方案,我刚刚检查了源代码管理,并且我得到了这个易于理解的错误:

...\AssemblyInfo.cs' could not be opened ('The system cannot find the file specified. ') (The file is fairly obviously missing)

...\AssemblyInfo.cs' 无法打开('系统找不到指定的文件。')(该文件相当明显丢失)

Because this file's automatically generated, I've never paid it much heed before, and in VS 2003 (which I still work with day to day - pity me) it never seems to matter if it's missing.

因为这个文件是自动生成的,所以我以前从未注意过它,而且在 VS 2003(我仍然每天都在使用它 - 可惜我)中,它是否丢失似乎无关紧要。

So 2 questions: 1. How can I get VS 2005 to regenerate the file. 2. Could anyone explain to me in a couple of sentences what the assembly info file is all about, why it's generated, why it's a good idea to have an automatically generated file critical to my solution building etc etc.

所以 2 个问题: 1. 我怎样才能让 VS 2005 重新生成文件。2. 谁能用几句话向我解释程序集信息文件的全部内容,为什么生成它,为什么自动生成对我的解决方案构建至关重要的文件等是个好主意。

Thanks - Andrew.

谢谢 - 安德鲁。

Edit: OK, I've googling some more, and it's probably significant that this is in an Nunit Test Project.

编辑:好的,我已经在谷歌上搜索了更多,这在 Nunit 测试项目中可能很重要。

Update: Deleting the reference in solution explorer an Alex suggested did the trick, and the project now builds, but I'm not entirely happy with that as a solution. If the file is so unimportant, why is it generated in the first place? And if the file does perform a vital task, what am I missing out on by just deleting it?

更新:删除 Alex 建议的解决方案资源管理器中的参考可以解决问题,并且项目现在可以构建,但我对此作为解决方案并不完全满意。如果文件如此不重要,为什么首先生成它?如果该文件确实执行了一项重要任务,那么删除它我会错过什么?

Also, is it even possible to get it back? Either by getting VS to regenerate it, or by manually hacking one up (possibly using another as a template)?

还有,有没有可能找回来?是通过让 VS 重新生成它,还是通过手动修改一个(可能使用另一个作为模板)?

回答by Alex Reitbort

This file contains assembly-wide settings like assembly version, name, etc. It is automatically generated when you change those settings using properties pages of the project. You should have this file in the project with sort of transparent icon (I think it is in resource folder or something like this by default). Locate it in the project tree and delete it. Visual studio will stop looking for it during build.

该文件包含程序集范围的设置,如程序集版本、名称等。当您使用项目的属性页更改这些设置时,它会自动生成。您应该在项目中使用带有透明图标的文件(我认为默认情况下它在资源文件夹或类似的东西中)。在项目树中找到它并删除它。Visual Studio 将在构建期间停止寻找它。

PS: assuming the path starts with .. and not ... then this file should be located one folder up from the project in the source control. So you can try looking there.

PS:假设路径以 .. 而不是 ... 开头,那么这个文件应该位于源代码管理中项目的一个文件夹中。所以你可以试试看那里。