Visual Studio:如何从源代码管理中排除整个目录?
我有一个 Visual Studio 2008 项目,其中包含在预构建步骤中代码生成的文件。这些文件均不应包含在源代码管理中。我无法预测会有多少文件,或者它们的确切名称。 生成的文件通过通配符指令包含在 Visual Studio 项目文件中:
<ItemGroup>
<Content Include="CodeGen\*.xaml"/>
</ItemGroup>
Visual Studio 将所有生成的文件标记为“源代码管理的新文件”,这样当您不小心时,您将检查整个文件通过“文件>>源代码控制>>从源代码控制中排除选择”将文件排除在源代码控制之外,唯一发生变化的是 csproj.vspscc 文件;其中,每个文件一行,还有一个计数器:
"NUMBER_OF_EXCLUDED_FILES" = "2"
"EXCLUDED_FILE0" = "CodeGen\\File1.xaml"
"EXCLUDED_FILE1" = "CodeGen\\File2.xaml"
我正在寻找一种从源代码管理中排除所有代码生成的文件的方法,以便 Visual Studio 不会将任何文件识别为“新”或“已更改” ,无论文件夹的内容是什么。
源代码控制是 Perforce。
I've got a Visual Studio 2008 project that contains files that are code-generated in a pre-build step. None of these files should be included in source control. I cannot predict how many files there are going to be, or their exact name.
The generated files are included into the Visual Studio project file via a wildcard directive:
<ItemGroup>
<Content Include="CodeGen\*.xaml"/>
</ItemGroup>
Visual Studio marks all of the generated files as "new to source control", so that when you're not careful, you'll be checking the whole bunch in. By excluding the files from source control via "File >> Source Control >> Exclude selection from source control", the only thing that changes is the csproj.vspscc file; in it, there's one line per file, and a counter:
"NUMBER_OF_EXCLUDED_FILES" = "2"
"EXCLUDED_FILE0" = "CodeGen\\File1.xaml"
"EXCLUDED_FILE1" = "CodeGen\\File2.xaml"
What I'm looking for is a way to exclude all the code-generated files from source control so that Visual Studio will not recognize any file as "new" or "changed", no matter what's the content of the folder.
Source control is Perforce.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 Perforce 中修改工作区规范以自动忽略某些文件或目录。假设你的项目名为 Foo,你的工作空间名为 Bar,你可以有
其中负号表示该行指定要忽略的文件/目录,三个句点表示该路径下的所有文件和目录。
我假设这会导致这些文件被忽略,即使 Visual Studio 尝试添加它们。我没有使用过 Perforce/Visual Studio 集成,所以我不确定。
You can modify your workspace specification in Perforce to automatically ignore certain files or directories. Assuming your project name is Foo and your workspace is named Bar, you can have
Where the negative sign means that the line specifies files/directories to ignore, and the triple-period means all files and directories under this path.
I am assuming that this would cause those files to be ignored even if Visual Studio tries to add them. I've not used the Perforce/Visual Studio integration, so I don't know for sure.