-pathmap (C# Compiler Options)

The -pathmap compiler option specifies how to map physical paths to source path names output by the compiler.




path1 The full path to the source files in the current environment

sourcePath1 The source path substituted for path1 in any output files.

To specify multiple mapped source paths, separate each with a comma.


The compiler writes the source path into its output for the following reasons:

  1. The source path is substituted for an argument when the CallerFilePathAttribute is applied to an optional parameter.
  2. The source path is embedded in a PDB file.
  3. The path of the PDB file is embedded into a PE (portable executable) file.

This option maps each physical path on the machine where the compiler runs to a corresponding path that should be written in the output files.


Compile t.cs in the directory C:\work\tests and map that directory to \publish in the output:

csc -pathmap:C:\work\tests=\publish t.cs

See also