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

Notification

Icon
Error

Does not work with Fody
ylee
#1 Posted : Tuesday, June 19, 2012 10:30:06 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/15/2012(UTC)
Posts: 20

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Hi,

I just found NCrunch doesn't work with Fody, while Resharper works just fine.

For those not familiar with Fody, Fody is made by the same author as Notify Property Weaver. It "uses Mono.Cecil and an add-in based approach to modifying the IL of .net assemblies at compile time". More about Fody:
* http://code.google.com/p/fody/
* http://visualstudiogallery.msdn.microsoft.com/074a2a26-d034-46f1-8fe1-0da97265eb7a

Steps to reproduce the issue:

1. Install Fody;
2. Create a new project;
3. Select the project file in Solution Explorer, then Menu > Project > Fody > Enable;
4. Enable NCrunch;
5. Got the following errors:

[06:06:05.0221-BuildTask-41] ERROR (Compilation): ClassLibrary1.Fody: M:\NCrunch\5208\39\Tools\Fody\Fody.targets (14): The "Fody.WeavingTask" task could not be loaded from the assembly M:\NCrunch\5208\39\Tools\Fody\\Fody.dll. Could not load file or assembly 'file:///M:\NCrunch\5208\39\Tools\Fody\Fody.dll' or one of its dependencies. The system cannot find the file specified. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

I remember I got a similar issue when I try to open a project in Expression Blend, if Blend failed to open the solution (that is, only opened the target project), I got a error that Blend cannot find (project path)\Tools\Fody\Fody.dll.

I think both NCrunch and Blend looked at the wrong location, it seems both of them are looking for (project path)\Tools\Fody\Fody.dll, but actually the Fody.dll file is located at (solution path)\Tools\Fody\Fody.dll.

My system configurations:
NCrunch 1.40.0.23b
Fody 0.18.0.0
Visual Studio 2010
Windows 7 64bit
Remco
#2 Posted : Tuesday, June 19, 2012 10:35:23 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Ylee,

Most likely this is because the Fody binaries need to be included in the NCrunch workspace.

Try adding a reference them using the 'Additional files to include' configuration setting, specifying a relative path.. for example: ..\Tools\Fody\**.*
1 user thanked Remco for this useful post.
ylee on 6/19/2012(UTC)
ylee
#3 Posted : Tuesday, June 19, 2012 10:42:10 PM(UTC)
Rank: Member

Groups: Registered
Joined: 2/15/2012(UTC)
Posts: 20

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Remco;2226 wrote:
Hi Ylee,

Most likely this is because the Fody binaries need to be included in the NCrunch workspace.

Try adding a reference them using the 'Additional files to include' configuration setting, specifying a relative path.. for example: ..\Tools\Fody\**.*

Thanks for your fast reply. I added .\Tools\Fody\*.* to the NCrunch solution configuration, and it solves the issue perfectly!

Cheers!
1 user thanked ylee for this useful post.
Remco on 6/19/2012(UTC)
ylee
#4 Posted : Wednesday, June 20, 2012 12:01:19 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/15/2012(UTC)
Posts: 20

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
Spoken too soon. I also need to manually copy some dll files.

For example, I'm using PropertyChanged Fody addin, I need to copy:

(solution folder)/packages/PropertyChanged.Fody.<version number>./PropertyChanged.Fody.dll

to:

(solution folder)/Tools/Fody

or I will get error:

NCrunch: If you are experiencing problems in getting this project to build, have a look at https://www.ncrunch.net/...ng_project-build-issues
(0)#1: Fody: Could not find a weaver named 'PropertyChanged'.:

It would be great if NCrunch could work with Fody out of box :)
Remco
#5 Posted : Wednesday, June 20, 2012 6:20:41 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Is this something that could be achieved with a post-build event? Pre/post build events are disabled by default in NCrunch, but you can easily switch them on if you need to apply extra logic to your build process.

NCrunch itself doesn't really do any magic within your build process. It simply copies the files it knows about and executes the build in the same way as the build would run via a command line msbuild.exe call, so in all theory, it should be possible to solve just about any kind of problem by making sure the files are in the right place.

The problem with supporting relative-path referenced build extension frameworks OOTB is in automatically identifying the resources they need in order to run. This isn't something that is easy to do reliably, and I'm still working on a proper solution. Meanwhile, I find the best short term solution is in trying to educate people about how the workspacing works and how to use the Additional Files To Include setting if they're doing anything interesting.
ylee
#6 Posted : Wednesday, June 20, 2012 7:12:08 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/15/2012(UTC)
Posts: 20

Thanks: 6 times
Was thanked: 3 time(s) in 3 post(s)
I tried to enable pre/post build events, but it didn't work. I also tried to switch other settings on/off, but with no success.

According to Fody documentation, Fody looks the following locations for weaver dll files:
* SolutionDir/Packages
* SolutionDir/Tools
* ...

So this can be solved by adding .\packages\**.* to the 'Additional files to include' configuration setting. But this would copy all NuGet packages (~50MB for my current project) to NCrunch workspace.

I only want to copy:

(solution folder)\packages\PropertyChanged.Fody.1.25.0.0\PropertyChanged.Fody.dll

and

(solution folder)\packages\PropertyChanging.Fody.1.12.0.0\PropertyChanging.Fody.dll

I tried to add .\packages\*.Fody.*\*.Fody.dll to the 'Additional files to include' configuration, but got error:

NCrunch was unable to load this project because it contains a file path that is structurally abnormal and cannot be handled. The file path specified in the project causing this error is: D:\Development\TestNCrunch\.\packages\*.Fody.*
Remco
#7 Posted : Wednesday, June 20, 2012 10:17:08 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
If copying the all nuget files to your workspace is an issue, probably the best thing you can do would be to individually specify the Fody dependencies using wildcards, one on each line. For example:

packages\PropertyChanging.Fody.1.12.0.0\**.*
packages\SomethingElse.Fody.1.12.0.0\**.*
1 user thanked Remco for this useful post.
yanglee on 8/2/2012(UTC)
SimonCropp
#9 Posted : Friday, June 22, 2012 7:15:15 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/22/2012(UTC)
Posts: 5
Location: ACT

Was thanked: 4 time(s) in 3 post(s)
Remco

Is there anyway we can make NCrunch and Fody work together OOTB?
Remco
#10 Posted : Monday, June 25, 2012 12:18:56 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Simon -

Absolutely. I'll need to set some time aside to take a closer look at how Fody works so that I can best advise on an approach. Is your email address on the Fody website the best way to contact you? I'll make a note to have a look at this soon and will be in touch.


Cheers,

Remco
SimonCropp
#11 Posted : Monday, June 25, 2012 3:20:49 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/22/2012(UTC)
Posts: 5
Location: ACT

Was thanked: 4 time(s) in 3 post(s)
simon.cropp@gmail.com for email and google chat

https://twitter.com/#!/SimonCropp
1 user thanked SimonCropp for this useful post.
Remco on 6/25/2012(UTC)
yanglee
#8 Posted : Thursday, August 2, 2012 12:01:27 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
Remco;2239 wrote:
If copying the all nuget files to your workspace is an issue, probably the best thing you can do would be to individually specify the Fody dependencies using wildcards, one on each line. For example:

packages\PropertyChanging.Fody.1.12.0.0\**.*
packages\SomethingElse.Fody.1.12.0.0\**.*

Copying all nuget files to workspace could be a problem if workspace is located on ram disk.

I recently frequently get build errors due to lack of free space on my RAM disk, which has only 1 GB space.
SimonCropp
#12 Posted : Thursday, August 2, 2012 12:04:16 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 6/22/2012(UTC)
Posts: 5
Location: ACT

Was thanked: 4 time(s) in 3 post(s)
@yanglee

The suggestion was to only copy Fody packages

So for example

packages\PropertyChanging.Fody.1.12.0.0\**.*
packages\SomethingElse.Fody.1.12.0.0\**.*

Not "Copying all nuget files"

Also the fody packages are very small. PropertyChanging.Fody is only 43KB. And it is the largest

So this should not cause you any disk space problems.

feel free to ping me on twitter if this is not clear https://twitter.com/#!/SimonCropp
1 user thanked SimonCropp for this useful post.
yanglee on 8/2/2012(UTC)
yanglee
#13 Posted : Thursday, August 2, 2012 2:35:58 PM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/25/2012(UTC)
Posts: 89
Location: China

Thanks: 23 times
Was thanked: 19 time(s) in 18 post(s)
Ah, I just realized I have misread Remco's post.

Thanks Simon, I followed the instruction and the problem is solved.

Cheers, Yang
MikeDymond
#14 Posted : Thursday, March 28, 2019 6:35:28 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/28/2019(UTC)
Posts: 4
Location: United Kingdom

Sorry to raise this thread from the dead, but I am having exactly this problem and I cannot figure out how to resolve it. I am using the latest version of Fody and NCrunch.

Cheers Mike
Remco
#15 Posted : Thursday, March 28, 2019 9:44:34 PM(UTC)
Rank: NCrunch Developer

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

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

To clarify, is your build giving the same error as at the top of this thread?

If so, can you check that the Fody files correctly arranged in the NCrunch workspace? To view the workspace, right click the failed build in the Tests Window and go to Advanced->Browse to workspace.
MikeDymond
#16 Posted : Friday, March 29, 2019 2:26:41 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/28/2019(UTC)
Posts: 4
Location: United Kingdom

Hi

I cannot see an error in any of the NCrunch logs, but I could be looking in the wrong place.

What I am seeing is that if I run the tests using Resharper all of my tests pass, but if I run them in NCrunch I have 4 that are failing. Having looked at the 4 failing tests we have tracked it down to when run via Resharper, Fody is wrapping an EqualityCheck around all of our properties, but when run in NCrunch this is not happening.

I have installed the latest NCrunch and the latest Fody and weaver required.

Fody is installed in the specflow project as well as the project that contains the classes to be weaved.

I have looked in the workspace, but I have no idea what correctly arranged Fody files would look like so I can't really answer your question.

It feels like we are just missing one simple step. How should Fody and Ncrunch work together? Are there any steps we have to perform to get it to work?


Thank you in advance for all of your input, very much appreciated.

Cheers Mike
Remco
#17 Posted : Friday, March 29, 2019 10:14:49 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Mike,

Are you able to build a sample solution that can reproduce this problem?
MikeDymond
#18 Posted : Monday, April 1, 2019 10:14:34 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/28/2019(UTC)
Posts: 4
Location: United Kingdom

Hi Remco

I will try.

In the meantime is there any documentation on how to get Fody to work with NCrunch? Should I install Fody in the test project?

Cheers Mike
MikeDymond
#19 Posted : Monday, April 1, 2019 3:42:45 PM(UTC)
Rank: Newbie

Groups: Registered
Joined: 3/28/2019(UTC)
Posts: 4
Location: United Kingdom

Hi Remco

I have created a brand new project and everything works as expected. So there is just something weird happening in my main project.


method to test:
Code:

        private bool _stuff;

        public bool Stuff
        {
            get => _stuff;
            set
            {
                if (!value)
                {
                    throw new Exception("Should not get here");
                }

                SetProperty(ref _stuff, value);
            }
        }



Test code:
Code:
        [Test]
        public void Test1()
        {
            var vm = new MainPageViewModel();

            vm.Stuff = false; // if Fody is working this should not do anything as the equality check should prevent it

            vm.Stuff = true; // This should work because the property is being set to true.

            Assert.Pass();
        }




I have a test in the new project that will fail if Fody is not working. This test passes in NCrunch and in Resharper. I can then add [DoNotCheckEquality] to the method being tested and the test will now fail in both NCrunch and Resharper.

In my main project I now have exactly the same test. However it only passes in Resharper and fails in NCrunch. When I add [DoNotCheckEquality] the test fails in both NCrunch and Resharper.

I will keep digging but if you have any pointers in the meantime as to what could be causing this inconsistency I would be very greatfull.

Cheers Mike
Remco
#20 Posted : Tuesday, April 2, 2019 1:04:51 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Hi Mike,

Thanks for the extra details. To help with this further, I really need a sample that I can use to produce the problem in my own environment. Let me know if you manage to isolate it.
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.230 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download