开发者

Visual Studio: How to exclude whole directory from source control?

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 Perf开发者_Python百科orce.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜