Dot-Net
DeploymentItemAttribute 的相對路徑根是什麼?
使用MSTest , DeploymentItemAttribute的相對路徑根是什麼。
根據MSDN頁面…
相對路徑相對於 .testrunconfig 文件中的 RelativePathRoot 設置。
預設情況下,該設置是解決方案目錄。所以,如果你有這個項目結構
SecretProject\ ComponentA\ ComponentA.Test\ Resources\ required.xml ComponentA.Test.csproj Tests.cs SecretProject.sln你想部署required.xml,你要像這樣創建一個 DeploymentItemAttribute
[TestClass] public class Tests { [TestMethod] [DeploymentItem("ComponentA.Test\Resources\required.xml")] public void Test() { } }似乎需要將文件屬性設置為“內容”和“始終複製”或“如果較新則複製”。此 MSDN 頁面上有高級範例。