views:

227

answers:

1

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.

+4  A: 

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.

Caleb Huitt - cjhuitt
Tried: Visual Studio still recognizes files as new, but Perforce won't let you check it in. So this is a partial solutions; in addition all users (>20) will have to modify their workspaces in all code branches (> 10)... A lot better than before though, thanks
GreenIcicle
@GreenIcicle: You might be able to set up a server-side trigger that strips files with a given path element ("CodeGen") from the list of files committed. That would solve your problem with so many users and workspaces, but I've never worked with the server-side stuff before, so I don't know for sure how it would work.
Caleb Huitt - cjhuitt