|
| 1 | +--- |
| 2 | +description: "Learn more about: -pathmap" |
| 3 | +title: "-pathmap" |
| 4 | +ms.date: 09/04/2025 |
| 5 | +f1_keywords: |
| 6 | + - "pathmap" |
| 7 | + - "-pathmap" |
| 8 | +helpviewer_keywords: |
| 9 | + - "-pathmap compiler option [Visual Basic]" |
| 10 | + - "/pathmap compiler option [Visual Basic]" |
| 11 | + - "pathmap compiler option [Visual Basic]" |
| 12 | +ai-usage: ai-generated |
| 13 | +--- |
| 14 | +# -pathmap |
| 15 | + |
| 16 | +Specifies how to map physical paths to source path names output by the compiler. |
| 17 | + |
| 18 | +## Syntax |
| 19 | + |
| 20 | +```console |
| 21 | +-pathmap:path1=sourcePath1,path2=sourcePath2 |
| 22 | +``` |
| 23 | + |
| 24 | +## Arguments |
| 25 | + |
| 26 | +| Term | Definition | |
| 27 | +|----------------|-----------------------------------------------------------------------------| |
| 28 | +| `path1` | Required. The full path to the source files in the current environment. | |
| 29 | +| `sourcePath1` | Required. The source path substituted for `path1` in any output files. | |
| 30 | + |
| 31 | +## Remarks |
| 32 | + |
| 33 | +> [!NOTE] |
| 34 | +> Specifying `-pathmap` prevents breakpoints from working in local debug builds. Only set `-pathmap` for production or continuous integration builds. |
| 35 | +
|
| 36 | +The `-pathmap` compiler option specifies how to map physical paths to source path names output by the compiler. 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. |
| 37 | + |
| 38 | +To specify multiple mapped source paths, separate each with a comma. |
| 39 | + |
| 40 | +The compiler writes the source path into its output for the following reasons: |
| 41 | + |
| 42 | +- The source path is substituted for an argument when the <xref:System.Runtime.CompilerServices.CallerFilePathAttribute> is applied to an optional parameter. |
| 43 | +- The source path is embedded in a PDB file. |
| 44 | +- The path of the PDB file is embedded into a PE (portable executable) file. |
| 45 | + |
| 46 | +The `-pathmap` option is not available from within the Visual Studio development environment; it's available only when compiling from the command line. |
| 47 | + |
| 48 | +## Example |
| 49 | + |
| 50 | +The following example compiles `Test.vb` and maps the source paths: |
| 51 | + |
| 52 | +```console |
| 53 | +vbc -pathmap:C:\MyProject\=\BuildServer\,C:\Temp\=\BuildTemp\ Test.vb |
| 54 | +``` |
| 55 | + |
| 56 | +In this example, if a source file is located at `C:\MyProject\Program.vb`, it will appear in the output as `\BuildServer\Program.vb`. |
| 57 | + |
| 58 | +## See also |
| 59 | + |
| 60 | +- [Visual Basic Command-Line Compiler](index.md) |
| 61 | +- [Sample Compilation Command Lines](sample-compilation-command-lines.md) |
| 62 | +- <xref:System.Runtime.CompilerServices.CallerFilePathAttribute> |
0 commit comments