I am writing a test code (I’m just a beginner) where I need to give a file name located in my local box. I need to check-in this code as well as the file in TFS, so that when other people take latest version, they get both.
//At my local box
string myFilePath= "D:\BACKUP\samplefile.extension";
For TFS check-in, I gave following path but it failed
string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension";
Now my question is:
- How can I specify the file path in my Code, so that after check-in when other people in my team take the latest version, the code will point to right file location in TFS?
Here’s how you can proceed:
Copy to Output Directory: Copy always. For example addtest.txt. Because the file is part of the project structure it will be added under source control as all the other files.Use the
[DeploymentItem]attribute in your unit test to indicate which file will be used. You also have the possibility to organize the test files into sub-folders.