问题
Is there any built-in macro to obtain the TFS Sourcecontrol Root directory in Visual Studio?
For example just like $(ProjectDir), I would use $(TFSSourceControlRoot) or something like that?
The reason I need this is to in order to use this path in the xcopy command which I will need as a part of a post build action. Instead of writing something like C:\Source\Scripts, I want to write something like $(TFSSourceControlRootDir)\Source\Scripts.
回答1:
If you mean the root of the folder structure on the server, then you can refer to it as simply $/
. However, if you mean the local folder that this is mapped to, there's not a macro for that. The reason is that you can map any number of folders in the server hierarchy to local disk folders, so there's not necessarily a single root - and there's not necessarily a folder that maps to $/
at all.
(That said, if you can explain why you need it, there might be alternative suggestions...)
回答2:
For newer searchers, I found this build variable page, and this is TFS 2015 specific, but it has:
BUILD_SOURCESDIRECTORY
The local path on the agent where your source code files are downloaded. For example: c:\agent_work\1\s.
来源:https://stackoverflow.com/questions/13693102/is-there-any-macro-to-get-the-root-directory-of-the-tfs-sourcecontrol-in-visual