urasandesu / Prig

Prig is a lightweight framework for test indirections in .NET Framework.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to share unit test with team

esenpillai opened this issue · comments

"Everything worked fine in my box", when my team mate download source code from source control and have the prig presetup done already (registration). We are getting below error.

The command "cmd /c " "%VS140COMNTOOLS%VsDevCmd.bat" & %windir%\SysNative\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoLogo -NoProfile -File "%URASANDESU_PRIG_PACKAGE_FOLDER%\tools\Invoke-PilotStubber.ps1" -ReferenceFrom "@('%URASANDESU_PRIG_PACKAGE_FOLDER%\lib\Urasandesu.NAnonym.dll','%URASANDESU_PRIG_PACKAGE_FOLDER%\lib\Urasandesu.Prig.Framework.dll')" -AssemblyFrom "D:\sourceroot\project1\bin\debug\project1.dll"..... exited with code -1.

Each our team member has different local folderr map with our source control. Should we all use same local map? Is there work around for this issue.

Umm... It seems that something is wrong, but I can't reproduce it currently.

In your error, there is a concrete value only in -AssemblyFrom option. -AssemblyFrom option is generated by Prig automatically when choosing Add Prig Assembly menu. The algorithm can be found in %URASANDESU_PRIG_PACKAGE_FOLDER%\tools\Add-PrigAssembly.ps1 line 105-113:

  1. Prig confirms whether the target for Prig Assembly is located in the directory under the sln.
  2. If 1. is true, Prig converts the path of the target to the relative path that is from $(ProjectDir).
  3. Otherwise, Prig uses the path of the target assembly directly.

If satisfying the condition 3 -- the target for Prig Assembly is NOT located in the directory under the sln, this phenomenon will be occur. However, you don't adopt such complex sln structure, do you? Also, the sample you provided previously was no problem against this point.

I will investigate this cause, but I maybe have difficult to resolve.

If you are in haste, please rewrite -AssemblyFrom option to the relative path follow your project manually. You can find it at BeforeRebuild and BeforeBuild target in the csproj of your test project. For example, rewrite -AssemblyFrom "D:\sourceroot\project1\bin\debug\project1.dll" to -AssemblyFrom "$(ProjectDir)..\..\..\project1\bin\debug\project1.dll".

Yes, my case is condition 3. We have a third party assembly which is referred using relative path. Ex: ../../../ThirdPartydlls/pro1/pro1.dll

Where as prig is referring it using direct path (ex: c:\ThirdPartydlls/pro1/pro1.dll). Would it be possible to use the same path (relative) used in reference. if we refer a assembly using direct path then it makes sense that prig uses the same direct path. In my case I am using relative path and expecting prig to use same relative path.

Yes your suggested workaround of manually correcting to relative path works.

Yes your suggested workaround of manually correcting to relative path works.

I'm relieved to hear that you could workaround though temporary 😌

Originally, my intent for condition 3 was "The target for Prig Assembly is in GAC (e.g. mscorlib).". Because GAC location cannot represent the relative path from sln.

I hadn't thought of your case. I'm going to review the algorithm to resolve it for the next release.

MEMO
Some problems are remaining when satisfying the following all conditions:

  • The assembly is NOT in GAC.
  • The assembly can add through "Add Reference" dialog box.

In this case, Add Prig Assembly menu doesn't work though showing the successful message like "Completed adding Prig Assembly for blah blah blah."