Could not find file "C: \ BuildAgent \ temp \ buildTmp \ SYSTEM_ [AGENT NAME] 2013-02-06 16_25_11 \

I have an MSTest build step in my TeamCity build. Some of the tests look for a file in a relative path that they cannot find, and the tests throw an error ...

Unable to find the path ...

'C: \ BuildAgent \ temp \ buildTmp \ SYSTEM_ [AGENT NAME] 2013-02-06 16_25_11 \ Documents \ json.value.list.txt'

I have a PowerShell script that I want to use to create and copy a file in the above path. However, I cannot find suitable TeamCity options to use the path ...

I have...

% system.teamcity.build.tempDir% \% teamcity.agent.name% \ documents

However, this gives me ...

'C: \ BuildAgent \ temp \ buildTmp [AGENT NAME] \ Documents \'

What parameters or TeamCity variables can be used to build ...

C: \ BuildAgent \ temp \ buildTmp \ SYSTEM_ [AGENT NAME] 2013-02-06 16_25_11 \ Documents

Thanks!

+4
source share
1 answer

If your test reads the contents of the file, this ensures that relative paths are resolved correctly, so tests can be performed both in TeamCity and locally:

string currentDir = new System.Diagnostics.StackFrame(true).GetFileName(); var workingFile = new FileInfo(currentDir); string fileContents = File.ReadAllText(workingFile.Directory + relativeFilePath); 

relativeFilePath is a variable containing the file. fileContents will contain the contents of this file when launched from TeamCity or locally.

0
source

All Articles