[英]How do I give file path for code to be checked in at TFS?
我正在编写一个测试代码(我只是一个初学者),需要在本地框中指定文件名。 我需要检入此代码以及TFS中的文件,以便其他人获取最新版本时,他们都能得到。
//At my local box
string myFilePath= "D:\BACKUP\samplefile.extension";
对于TFS签入,我给出了以下路径,但失败了
string myFilePath= "$MyProjectServer\SomeFolder\samplefile.extension";
现在我的问题是:
您可以按照以下步骤进行操作:
Copy to Output Directory: Copy always
。 例如,添加test.txt
。 由于该文件是项目结构的一部分,因此它将像其他所有文件一样在源代码控制下添加。 在单元测试中使用[DeploymentItem]
属性指示将使用哪个文件。 您还可以将测试文件组织到子文件夹中。
[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"); }
您的TFS路径string myFilePath= "$MyProjectServer\\SomeFolder\\samplefile.extension"
格式错误。
itemspec的正确格式为:
string myFilePath= "$/MyProjectServer/SomeFolder/samplefile.extension";
请注意,在$
后面添加了斜杠,并且在整个过程中将反斜杠更改为正斜杠。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.