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

Notification

Icon
Error

Fody: Mono.Cecil.Mdb assembly not found
Luciferius
#1 Posted : Monday, September 7, 2015 6:47:53 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Hello,

I have a problem with the Fody build step. When I build my test assembly I get the following error:

Code:
Fody: An unhandled exception occurred:
Exception:
Die Datei oder Assembly "Mono.Cecil.Mdb, Version=0.9.6.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
StackTrace:
   bei InnerWeaver.GetSymbolProviders()
   bei InnerWeaver.Execute()
Source:
FodyIsolated
TargetSite:
Void GetSymbolProviders()


I have than looked into the "_ncrunchreferences" build folder and there is a .dll file Mono.Cecil.Mdb.dll with the version 0.9.6.0.
Is there anything I can do to make it work?

Best regards.
Remco
#2 Posted : Monday, September 7, 2015 8:49:19 AM(UTC)
Rank: NCrunch Developer

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

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

Are you referencing Fody using Nuget? It's possible that Fody is looking for this binary inside the Nuget packages directory.

If this is the case, try adding the Fody Nuget package directory to the 'Additional files to include' project-level NCrunch configuration setting. This should make NCrunch copy the file to the workspace in a location where the Fody build steps can find it.
Luciferius
#3 Posted : Monday, September 7, 2015 9:20:11 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
I am not using Nuget. And it does find the Fody assembly only the specific Mono.Cecil.Mdb can not be found. I use the version 1.29.3 of Fody.
Luciferius
#4 Posted : Monday, September 7, 2015 11:29:07 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
For some magical reason I do not understand, it now works. I changed nothing just waited. But now there is another problem. I have a pre build step which copies the FodyWeavers.xml to every test assembly I have. with this I have no maintenance when I create a new test assembly. The pre build command look like:
Code:
FOR /F %%A in ('dir /b "$(SolutionDir)\Test.*"') DO (
    XCOPY "$(SolutionDir)\Lib\AFComponents\Tools\Fody\config\UnitTest\FodyWeavers.xml" "$(SolutionDir)\%%A\" /Y /D /Q
)

This does not work with NCrunch, which is not surprising when I look at the folder structure which NCrunch uses. Is there a possibility to make it work anyway? Should I create a new topic for it?
Remco
#5 Posted : Monday, September 7, 2015 9:41:10 PM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Can you share any more details about what this build step is trying to achieve? My guess is that it is copying a file into every test directory .. is there a reason for this?
Luciferius
#6 Posted : Tuesday, September 8, 2015 5:03:46 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Yes, with Fody I add some additional attributes above all test methods in all test projects. For this I need the "FodyWeavers.xml" file as config file inside the source directory of the test assemblies. Because they are all identical I have just one config file which I copy with the above pre build step into each test folder. The pre build step only exists inside basic test project which is referenced by all other projects. As I explained above this reduces the maintenance overhead for me when I create a new test project. With ncrunch I have seen, that there are separate folders for each test project and their sources. Therefore this pre build step only copies the "FodyWeavers.xml" file into the basic test assembly, but not into any other assembly. This in the end leads to build errors.
A possible, but not the best workaround would be to exclude the Fody task from the build, if that is even possible. Better would be a possibility to copy the config file to every test project as I do in the normal environment.
Remco
#7 Posted : Tuesday, September 8, 2015 6:42:07 AM(UTC)
Rank: NCrunch Developer

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

Thanks: 931 times
Was thanked: 1257 time(s) in 1170 post(s)
Luciferius;7702 wrote:
Yes, with Fody I add some additional attributes above all test methods in all test projects. For this I need the "FodyWeavers.xml" file as config file inside the source directory of the test assemblies. Because they are all identical I have just one config file which I copy with the above pre build step into each test folder. The pre build step only exists inside basic test project which is referenced by all other projects. As I explained above this reduces the maintenance overhead for me when I create a new test project. With ncrunch I have seen, that there are separate folders for each test project and their sources. Therefore this pre build step only copies the "FodyWeavers.xml" file into the basic test assembly, but not into any other assembly. This in the end leads to build errors.
A possible, but not the best workaround would be to exclude the Fody task from the build, if that is even possible. Better would be a possibility to copy the config file to every test project as I do in the normal environment.


Gotcha. This makes sense, and we can make this work with NCrunch .. but it will need to be redesigned slightly.

For NCrunch to do its work, it needs to be able to separate each project from the parent solution. Although there is a certain level of emulation that it can perform to do this (like making a fake $(SolutionDir)), projects do still need to have a certain level of atomicity. This means that it isn't really possible to have one project that implicitly copies files into the working directory of another project.

The solution to this is to have a pre-build step inside each of the test projects so that each one can copy the config file into its own working directory. For NCrunch to be able to perform the build step, each test project will also need to have a declared dependency on the file that needs to be copied - this can be done using either the 'Additional files to include' setting (for each project) or by including the file inside each project using a build item inside the project XML.

I realise this probably is going to seem rather repetitive as you'll end up with the same copy logic inside each test project, but there is a way to re-use this logic by including a custom build targets file. If you create your own .targets file and <Import> this into each of your test projects, you'll be able to place both the build item and the pre-build step inside this .targets file. Having a shared build targets file is also very useful to have if you need to introduce other common build logic in future.

I hope this makes sense .. do let me know if you need me to clarify the above a bit further.
Luciferius
#8 Posted : Tuesday, September 8, 2015 8:50:32 AM(UTC)
Rank: Member

Groups: Registered
Joined: 2/28/2013(UTC)
Posts: 22

Thanks: 2 times
Was thanked: 4 time(s) in 4 post(s)
Thanks for your help. This solution works for me.
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.048 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download