I encounted this error on the TeamCity build server. I finally resolved it after checking the build log and found:
“‘xcopy’ is not recognized as an internal or external command.”
I then changed my statement to:
C:\Windows\System32\xcopy “$(ProjectDir)config\Web.config.$(ConfigurationName)” “$(ProjectDir)Web.config” /Y/R