확인. DeploymentItem은이를 해결하는 방법입니다. 그러나 DeploymentItem은 약간 깨지기 쉽습니다.
다음은 어떻게 수정 했습니까?
"현재 디렉터리"는 DeploymentItem과 일치해야합니다. 내가 찾은 최고의 절충점은 현재 디렉토리를 .sln 파일의 위치로 설정하는 것입니다.
내 폴더 구조는 다음과 같습니다.
C:\SomeRootFolder\
C:\SomeRootFolder\MySolution.sln
C:\SomeRootFolder\packages\
C:\SomeRootFolder\packages\MyNugetPackage.1.2.3.4\lib\net45\SomeThirdPartyDll.dll
C:\SomeRootFolder\MyTestProject\MyTestProject.csproj
C:\SomeRootFolder\MyTestProject\MyTestClass.cs
MyTestClass.cs
[TestClass]
public class MyTestClass
{
[TestMethod]
/* The DeploymentItem item below is for error ::: Warning: Test Run deployment issue: The assembly or module 'SomeDll' directly or indirectly referenced by the test container 'C:\SomeRootFolder\MyTestProject\bin\debug\MyTestProject.dll' was not found. */
/* There must be a CD (to the .sln folder) command... before the MsTest.exe command is executed */
[DeploymentItem(@".\packages\MyNugetPackage.1.2.3.4\lib\net45\SomeDll.dll")]
public void MyTest()
{
}
}
은 "트릭"
은의 .sln 주택 폴더로 CD (디렉토리 변경)을하는 것입니다. "현재 디렉토리"(CD의 결과)에 있기 때문에
REM Now the normal restore,build lines
nuget.exe restore "C:\SomeRootFolder\MySolution.sln"
REM the above nuget restore would create "C:\SomeRootFolder\packages\MyNugetPackage.1.2.3.4\lib\net45\SomeThirdPartyDll.dll"
MSBuild.exe "C:\SomeRootFolder\MySolution.sln" /p:Configuration=Debug;FavoriteFood=Popeyes /l:FileLogger,Microsoft.Build.Engine;logfile=MySolution.Debug.Build.log
REM (the below line is the trick to line up the 'current folder' with the relative path of the DeploymentItem)
cd "C:\SomeRootFolder\"
REM now the below will work without the annoying message, note that C:\SomeRootFolder\MyTestProject\bin\Debug\SomeThirdPartyDll.dll exists
MsTest.exe /testcontainer:"C:\SomeRootFolder\MyTestProject\bin\Debug\MyTestProject.dll" /resultsfile:MyTestProject.Dll.Results.trx
지금 "C : \ SomeRootFolder \"는 DeploymentItem 상대 경로가 제대로 작동합니다.
Jimminy Crickets ....... 그건 좀 괴롭다.
주, 폴 테일러는
Running MsTest from the command line with a custom assembly base directory
나를 위해 작동하지 않았다 여기에 답합니다.
감사합니다. 내 문제를 해결합니다. – aeruL