TfsDeployer deleting files

Apr 9, 2011 at 10:50 PM

Why does TfsDeployer 1.4 delete files it shouldn't be deleting?

I extracted it to Program Files\TfsDeployer.  If run from the command line using -d, it deletes all of the files except for the DLLs in the TfsDeployer folder after the first trigger.

When I ran it as a service, it screwed up the XP machine it was running on.  Can't login to the machine anymore.

Apr 10, 2011 at 11:57 PM


This is the first time this kind of behaviour has been reported and I'd like to work with you to discover the underlying cause so it can also be the last time.

The only part of TFS Deployer that deletes files that comes to mind is the stage where it cleans up the temporary TFS workspace used to download the Deployment files. The TFS workspace should be located in the TEMP directory of the user TFS Deployer is running as and so only files in there should be deleted. if you enter "echo %TEMP%" from the same command line as you executed "TFSDeployer.exe -d" does it return the expected location?

Is it also possible there is something in the Deployment script that TFS Deployer has been configured to run when triggered that has delete statements?



Apr 11, 2011 at 1:27 AM

Hi Jason,

Thanks for your willingness to help.

I did an echo %TEMP%, and it is set to the current user's temp directory.  I also noticed when running "TFSDeployer.exe -d" with trace turned on that the temp directory was referenced as the workspace directory.

However, I just looked at my script, and noticed that it is incorrect and there is a remove statement.  I'm new to PowerShell (haven't had the time to delve into it) so I'm not sure what the repercussions are.  I copied this script from the installation instructions and modified it.  Notice that $Destination is never defined, however it's referenced.  Could this be causing the problem?

$AppServiceDestination = "Y:\testdeploy\VrAppServce\bin\"
$RptServiceDestination = "Y:\testdeploy\VrRptService\bin\"
$WebDestination = "Y:\testdeploy\VrWeb\bin\"
$XBAPDestination = "Y:\testdeploy\VrWeb\XBAP\"
New-Item -ItemType Directory -Path $Destination -Force
Get-ChildItem -Path $Destination | Remove-Item -Recurse -Force



Apr 11, 2011 at 7:10 AM

Hi Bob,

From a quick test, executing "Get-ChildItem -Path $Destination" when the $Destination variable is not defined will return the contents of the current directory. Piping this to Remove-Item will then attempt to delete everything in the current directory.

When running TFSDeployer.exe -d, the current directory for the script is most likely the TFS Deployer install location (hence all the files except the DLLs being deleted [the DLLs would be locked while executing]).

When running TFSDeployer as a service (especially when running as the Local System account) the current directory would probably be the Windows System folder.

I've raised an Issue to fix TFS Deployer so that the current directory is set to a safer location to avoid this kind of problem in the future.

Until then I recommend using the following statement at the beginning of your PowerShell scripts to cause it to error when using an undefined variable (great for detecting typos):
Set-StrictMode -Version Latest