问题
I am running a Invoke Command at the end of my build. I am trying to get it to run a batch file.
But I don't want to hard code the path to the batch file (in case I move my build to a different build server).
I need a variable to put in for the WorkingDirectory of IvokeProcess. In TFS 2008 Build I would have used $(SolutionDir)
. But I can't find anything like that in TFS 2010 Build. (I tried Environment.CurrentDirectory and I got C:\Windows\System32
What can I do to get a reference to the path that my solution (or project) is in.
回答1:
I would advise against focusing on the 'Working Directory' for the type of task you 're trying to accomplish.
You can open your build process template & add a new Argument (type = string, Direction = In), with default value equaling the current full path to your batch file.
Then set this in argument in your InvokeProcess activity. Here is how I invoke NCover:
In the default value I have simply set "C:\Program Files\NCover\NCover.Console.exe"
Now each build definition has an additional parameter (under 'Process'), with default value the one that currently makes sense.
Should we move to another build server, I would have to simply update the build definitions.
来源:https://stackoverflow.com/questions/7179564/variable-of-solution-directory-or-something-close-in-tfs-2010-build