Your workspace may include files that you do not want to add to the Perforce repository, such as files used or generated by automated build processes.
You can use Visual Studio to exclude a file from a solution by context-clicking the file in Solution Explorer and selecting Exclude from Project in the context menu. If the file is under Perforce control, P4VS prompts you to mark the file for delete, and after submitting the changelist that includes the deletions, the file is removed from both the project and the Perforce repository.
You can also use Ignore Lists in P4VS to specify files or filetypes
that you want to keep in your project but do not want to add to the Perforce
repository. An Ignore List is a file in your local workspace directory that
contains a list of file names or file types to ignore. For example, you can
create an Ignore List called
.p4ignore in your project folder that
contains the following:
(Note that the Ignore List file itself is included in the list.)
You can add an Ignore List file at any level of the solution hierarchy in
your workspace. If you set your
P4IGNORE environment variable to
the file name of the Ignore List file, P4VS will not mark the listed files and
filetypes for add, nor will it prompt you to do so.
Ignore Lists only affect commands that search for and add new files. If you have already marked a file for add, P4VS will no longer ignore it, even if it or its filetype appear in an Ignore List.
You can add Ignore Lists at any folder level in your workspace (or
solution). P4VS applies the rules in the Ignore List at the deepest folder
level relative to the file being checked, along with the rules in any Ignore
Lists found in parent folders (although you can use the
character to override higher-level rules.)
The syntax for ignore rules is not the same as Perforce syntax. Instead, it is similar to that used by other versioning systems:
#at the beginning of a line denotes a comment
!at the beginning of a line excludes the file specification
*wildcard matches substrings
||Ignore files called "foo.txt"|
||Ignore all executables|
While you can set your local
P4IGNORE environment variable and
add Ignore Lists manually, P4VS provides preferences and context menu options
to simplify the process of adding and editing Ignore Lists.
Go to Tools>Options>Source Control>Perforce - Ignoring
Files to set Ignore List preferences, including the Ignore List file
name. The file name you enter in your preferences is set by P4VS as the local
P4IGNORE environment variable and used for all of your Ignore
Lists. For more information about setting Ignore List preferences, see Setting Perforce preferences.
In Visual Studio 2012, P4VS denotes an ignored file with a gray circle glyph next to the file icon. In Visual Studio 2008 and 2010, P4VS denotes an ignored file by removing the blue question mark glyph: .
To remove a file from an Ignore List in Solution Explorer, context-click the
file and select Manage Files>Remove from Ignore List. P4VS
adds an exclusionary (
!) line for the file in the Ignore List in
the current folder, which overrides any Ignore Lists in parent folders.
To edit an Ignore List in Solution Explorer, context-click any file in the same folder and select Manage Files>Edit Ignore List. P4VS opens the Ignore List file for edit. If there is no Ignore List file in the current folder, P4VS creates one. Use Edit Ignore List when you want to add file types using wildcard expressions.