Fody: Visual Studio 2017 RC cannot find Microsoft.Build.Framework
Cross posting from the Costura repo where I originally posted this https://github.com/Fody/Costura/issues/173
Seems that an unmodified project that is building fine in VS2015 using Costura.Fody can’t find the Microsoft Build framework and throws the following exception at compile time
Error Fody: An unhandled exception occurred:
Exception:
Could not load file or assembly 'Microsoft.Build.Framework, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
StackTrace:
Server stack trace:
at System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
at System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
at System.Reflection.RuntimeMethodInfo.GetParameters()
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at IInnerWeaver.set_Logger(ILogger value)
at Processor.ExecuteInOwnAppDomain() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\Fody\Processor.cs:line 146
at Processor.Inner() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\Fody\Processor.cs:line 93
at Processor.Execute() in c:\ConsoleBuildAgent\work\ed448661dbb30d2e\Fody\Processor.cs:line 45
Source:
mscorlib
TargetSite:
Void GetSignature(Void*, Int32, System.RuntimeFieldHandleInternal, System.IRuntimeMethodInfo, System.RuntimeType)
Could not load file or assembly 'Microsoft.Build.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
StackTrace: DiagnosticsSharp.Runner
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 27 (14 by maintainers)
Sorry I have found the problem, my project was using an older version of Fody, I have upgraded the package to version 29 and everything is working now
I’ve just run into this problem today. It seems to go away if you install MSBuild version 14 - which is the one associated with VS2015. https://www.microsoft.com/en-us/download/details.aspx?id=48159
I ran into a similar issue this evening and did some investigation that I hope will provide useful information to others…
Here is the relevant portion from the MSBuild output
Clearly something is failing to load the Microsoft.Build.Framework assembly. Examining my weaver I can see that it is compiled against version 4.0.0.0 (ILDasm)
Firing up Fuslog the problem is a little more clear:
Of particular interest are these two lines:
Looking into the new MSBuild.exe.config file and sure enough there is a binding redirect to forward all versions of Microsoft.Build.Framework to version 15.1.0.0
So I then decided to take a peek to see why my weaver was relying on the Microsoft.Build.Framework. As it turns out I had started my weaver by copying the default weaver which contains this line:
The
MessageImportanceclass lives in the Microsoft.Build.Framework. Since I was not using this property I simply removed it and the reference to Microsoft.Build.Framework and my problem was solved. However I suspect this issue may end up breaking other weavers.Looking into it more, it appears that Fody loads the weaver assemblies from byte arrays which causes them to be loaded without context. Which I suspect this is likely the reason for it not being able to resolve the dependency. Any thoughts on how this could be addressed?