[英]How do I give file path for code to be checked in at TFS?
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.
我需要检入此代码以及TFS中的文件,以便其他人获取最新版本时,他们都能得到。
//At my local box
string myFilePath= "D:\BACKUP\samplefile.extension";
For TFS check-in, I gave following path but it failed 对于TFS签入,我给出了以下路径,但失败了
string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension";
Now my question is: 现在我的问题是:
Here's how you can proceed: 您可以按照以下步骤进行操作:
Copy to Output Directory: Copy always
. Copy to Output Directory: Copy always
。 For example add test.txt
. test.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. 在单元测试中使用
[DeploymentItem]
属性指示将使用哪个文件。 You also have the possibility to organize the test files into sub-folders. 您还可以将测试文件组织到子文件夹中。
[TestMethod] [DeploymentItem("test.txt")] public void Index() { // use relative path to read the file var actual = File.ReadAllText("test.txt"); Assert.AreEqual(actual, "some content"); }
Your TFS path string myFilePath= "$MyProjectServer\\SomeFolder\\samplefile.extension"
is in the wrong format. 您的TFS路径
string myFilePath= "$MyProjectServer\\SomeFolder\\samplefile.extension"
格式错误。
The correct format for an itemspec is: itemspec的正确格式为:
string myFilePath= "$/MyProjectServer/SomeFolder/samplefile.extension";
Note the addition of the slash after the $
and the change of backslashes to forward slashes throughout. 请注意,在
$
后面添加了斜杠,并且在整个过程中将反斜杠更改为正斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.