Visual Studio 2015 External Tools arguments usage
Lately I’ve encountered problems with the usage of predefined variables available for External Tools in Visual Studio 2015. The problem was that I needed to pass the file currently opened in the VS Editor to external process.
The good part it that documentation for this tool (External) is available here. The bad part is that description exposed for available variables is quite parsimonious.
For a file there are actually three options:
- $(ItemPath) – The complete file name of the current file (drive + path + file name).
- $(ItemFilename) – The file name of the current file (file name).
- $(ItemExt) – The file name extension of the current file.
So far, so good. The wicked thing is that $(ItemPath) is with extension, i.e. fully qualified name, while $(ItemFilename) is without. But $(ItemExt) contains a dot as first character!
So the values for the above three variables would be:
- name (I’m not aware of why not name. for example)
- .ext (… why not ext [without dot] for example)
For absolute path – use item 1. For relative path use item 2 and 3 concatenated as shown in the picture below – i.e. $(ItemFilename)$(ItemExt) not
It is my mistake that I do not read documentation properly, but anyway I’d like to warn other lost souls that might bump in this.
The most wicked of of all is that in VS2015 Arguments field length is 251 chars!