Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Files copied in imported .targets file do not get copied into NCrunch workspace
Leonid
#1 Posted : Tuesday, September 15, 2015 8:36:36 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 1/2/2013(UTC)
Posts: 7
Location: United States of America

Thanks: 2 times
I ran into this NCrunch bug (or at least difference from VS build):

1. Create a class library ClassLibrary1 and a unit test project UnitTestProject1, with UnitTestProject1 referencing ClassLibrary1.

2. Create a folder "Targets" as a sibling to ClassLibrary1/UnitTestProject1 folders, and call it "Targets". Add a myTargets.targets file that has this:
Code:
<Project xmlns="(- BROKEN LINK -)">
    <ItemGroup Condition="'$(MSBuildThisFileDirectory)' != '' And HasTrailingSlash('$(MSBuildThisFileDirectory)')">
    <Content Include="$(MSBuildThisFileDirectory)\foo.txt">
      <Link>%(FileName).txt</Link>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>
  </ItemGroup>
</Project>


3. Add a file "foo.txt" in the Targets folder.

4. Add this line to ClassLibrary1.csproj:
<Import Project="..\Targets\MyTargets.targets" />

Now, when you build the project, foo.txt will be copied to the /bin/Debug folder of both ClassLibrary1 and UnitTestProject1.

However, if you navigate to the NCrunch workspace for UnitTestProject1, foo.txt is not there. (They are there for ClassLibrary1 though). Interestingly, it's not there for UnitTestProject1 even after you add foo.txt and MyTargets.targets to "Additional files to include".

In my case, the import was added via a NuGet package. The workaround for me was easy, just add the same NuGet to package to the unit test project. However, I expected it to just work.
Remco
#2 Posted : Tuesday, September 15, 2015 9:49:19 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 6,979

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi, thanks for sharing this issue.

I suspect you've hit this problem: http://www.ncrunch.net/documentation/considerations-and-constraints_assembly-colocation-assumptions. Although most of this documentation page talks about assembly references, the same issue also applies to resource files in referenced projects.

Does setting the 'Copy referenced assemblies to workspace' setting to 'True' on your unit test project resolve the issue?
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.026 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download