[英]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.