Visual Studio:如何从源代码管理中排除整个目录?

发布于 2024-08-23 03:18:32 字数 657 浏览 5 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苹果你个爱泡泡 2024-08-30 03:18:32

您可以在 Perforce 中修改工作区规范以自动忽略某些文件或目录。假设你的项目名为 Foo,你的工作空间名为 Bar,你可以有

//depot/Foo/... //Bar/...
-//depot/Foo/CodeGen/... //Bar/CodeGen/...

其中负号表示该行指定要忽略的文件/目录,三个句点表示该路径下的所有文件和目录。

我假设这会导致这些文件被忽略,即使 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

//depot/Foo/... //Bar/...
-//depot/Foo/CodeGen/... //Bar/CodeGen/...

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文