MsTest: how to set a deployment item relative to $ (ProjectDir) or $ (OutDir)

I want to add a deployment item to my test. As far as I understand so far, the path refers to the solution. I want the path to be relative to the project. Otherwise, the project cannot be used in several solutions. How to set up a deployment item relative to a project-specific variable?

I was hoping for something like: [DeploymentItem(@"$(ProjectDir)..\..\bin\$(Configuration)")]but I did not find any documentation and does not seem to work.


I just did a little test. Just a simple wizard code and one deployment item:

[TestMethod]
[DeploymentItem("stdafx.cpp")]
void TestMethod1()
{
    Assert::Fail();
};

and the trx file shows the following line:

: : 'stdafx.cpp', TestProject1.UnitTest1.TestMethod1: System.IO.FileNotFoundException: 'd:\Development\\deploymentItemTest\stdafx.cpp.         System.IO.FileNotFoundException: 'd:\Development\Projects\deploymentItemTest\stdafx.cpp'. : 'd:\Development\Projects\deploymentItemTest\stdafx.cpp'

, "stdafx.cpp" ( ... \depoymentItemTest), ( ...\depolymentItemTest\TestProject1)

+5
2

, , . :

  • :

    xcopy /I /S /Y  "$(TargetDir)*.*" "$(SolutionDir)\bin"
    

    ( ) "bin" .

  • DeploymentItem :

    [DeploymentItem ("bin")]
    

    bin

( ) , DeploymentItem

+3

Environment.CurrentDirectory.

+1

All Articles