Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update FSharp.Core reference in WebSharper.MSBuild #504

Closed
johannesegger opened this issue Dec 2, 2015 · 21 comments
Closed

Update FSharp.Core reference in WebSharper.MSBuild #504

johannesegger opened this issue Dec 2, 2015 · 21 comments

Comments

@johannesegger
Copy link

As of WebSharper 3.6.2.220 WebSharper.MSBuild references FSharp.Core 4.3.0.0. Since this version of FSharp.Core seems to be unavailable for an Azure WebJob and I'm not sure how to add binding redirects for MSBuild.exe WebSharper won't be able to build my website in Azure.
The only way I see to fix this is referencing a newer version of FSharp.Core. Any thoughts?

@Tarmil
Copy link
Member

Tarmil commented Dec 4, 2015

FSharp.Core 4.3.0.0 is included in the WebSharper NuGet package in the tools folder, next to WebSharper.MSBuild.dll, so the fact that it isn't available on Azure shouldn't be an issue. Do you have an exact error message that could help us find the problem?

@cgravill
Copy link

cgravill commented Dec 4, 2015

We have an equivalent problem and get the error message:

2015-12-04T17:26:15.6617977Z ##[error]packages\WebSharper.3.6.2.220\build\WebSharper.targets(60,5): Error MSB4018: The "WebSharperTask" task failed unexpectedly.
2015-12-04T17:26:15.6819454Z ##[error]System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
2015-12-04T17:26:15.6819454Z ##[error]File name: 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
2015-12-04T17:26:15.6819454Z ##[error]Server stack trace: 
2015-12-04T17:26:15.6819454Z ##[error]   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
2015-12-04T17:26:15.6931773Z ##[error]   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
2015-12-04T17:26:15.6931773Z ##[error]   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
2015-12-04T17:26:15.6931773Z ##[error]   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
2015-12-04T17:26:15.6931773Z ##[error]   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
2015-12-04T17:26:15.6931773Z ##[error]   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
2015-12-04T17:26:15.6931773Z ##[error]   at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
2015-12-04T17:26:15.6931773Z ##[error]   at System.Runtime.Remoting.Metadata.RemotingTypeCachedData.GetSoapAttributeNoLock()
2015-12-04T17:26:15.6931773Z ##[error]   at System.Runtime.Remoting.Metadata.RemotingCachedData.GetSoapAttribute()
2015-12-04T17:26:15.6931773Z ##[error]   at System.Runtime.Remoting.InternalRemotingServices.GetCachedSoapAttribute(Object reflectionObject)
2015-12-04T17:26:15.6931773Z ##[error]   at System.Runtime.Remoting.SoapServices.GetXmlTypeForInteropType(Type type, String& xmlType, String& xmlTypeNamespace)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Runtime.Remoting.RemotingServices.DetermineDefaultQualifiedTypeName(Type type)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, ConstructorCallMessage& ctorCallMsg)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
2015-12-04T17:26:15.7125314Z ##[error]   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
2015-12-04T17:26:15.7125314Z ##[error]   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
2015-12-04T17:26:15.7125314Z ##[error]   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
2015-12-04T17:26:15.7125314Z ##[error]   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
2015-12-04T17:26:15.7125314Z ##[error]   at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
2015-12-04T17:26:15.7125314Z ##[error]   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
2015-12-04T17:26:15.7125314Z ##[error]   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
2015-12-04T17:26:15.7242727Z ##[error]   at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
2015-12-04T17:26:15.7242727Z ##[error]   at WebSharper.MSBuild.WebSharperTask.Execute()
2015-12-04T17:26:15.7242727Z ##[error]   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
2015-12-04T17:26:15.7242727Z ##[error]   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
2015-12-04T17:26:15.7242727Z ##[error]Exception rethrown at [0]: 
2015-12-04T17:26:15.7242727Z ##[error]   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
2015-12-04T17:26:15.7242727Z ##[error]   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
2015-12-04T17:26:15.7242727Z ##[error]   at Microsoft.Build.Framework.ITask.Execute()
2015-12-04T17:26:15.7242727Z ##[error]   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2015-12-04T17:26:15.7242727Z ##[error]   at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2015-12-04T17:26:15.7242727Z ##[error]WRN: Assembly binding logging is turned OFF.
2015-12-04T17:26:15.7242727Z ##[error]To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
2015-12-04T17:26:15.7242727Z ##[error]Note: There is some performance penalty associated with assembly bind failure logging.
2015-12-04T17:26:15.7242727Z ##[error]To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

I've just started looking into it. This is running on the VSO build system, I have access to the agent so can collect additional logs if that'll help?

@cgravill
Copy link

cgravill commented Dec 4, 2015

In case it helps narrow the problem down it didn't happen with 3.5.3.203. We were upgrading to get the msbuild fix #486 which might be related.

@johannesegger
Copy link
Author

You're totally right, I didn't see that FSharp.Core 4.3.0.0 is in the same folder. But according to the assembly resolution rules the runtime doesn't search in this folder, does it?

I get this error from MSBuild (I think it's slightly different than @cgravill 's):

EDIT: I just saw it's basically the same, but I executed the WebSharperClean task (line 46 in WebSharper.targets) whereas @cgravill executed WebSharperCompile (line 60 in WebSharper.targets).

[12/01/2015 21:12:45 > 2c1536: INFO]      2>D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: The "WebSharperTask" task failed unexpectedly. [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: File name: 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: Server stack trace:  [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Metadata.RemotingTypeCachedData.GetSoapAttributeNoLock() [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Metadata.RemotingCachedData.GetSoapAttribute() [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.InternalRemotingServices.GetCachedSoapAttribute(Object reflectionObject) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.SoapServices.GetXmlTypeForInteropType(Type type, String& xmlType, String& xmlTypeNamespace) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.RemotingServices.DetermineDefaultQualifiedTypeName(Type type) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, ConstructorCallMessage& ctorCallMsg) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Activator.CreateInstance(Type type, Boolean nonPublic) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at WebSharper.MSBuild.WebSharperTask.Execute() [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: Exception rethrown at [0]:  [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at Microsoft.Build.Framework.ITask.Execute() [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: WRN: Assembly binding logging is turned OFF. [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging. [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
[12/01/2015 21:12:45 > 2c1536: INFO] D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\packages\WebSharper\build\WebSharper.targets(46,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\oybo0swf.jbo\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]

@cgravill
Copy link

cgravill commented Dec 6, 2015

Based on comments to another issue #468 I've been able to workaround this by adding a binding redirect in MSBuild.exe.config so it targets 4.3.1.0.

@johannesegger
Copy link
Author

I digged a bit through the code in WebSharper.MSBuild and it seems that they added code to solve this (i.e. if necessary they create a custom app domain and add a handler to AppDomain.AssemblyResolve). I just can't figure out why this seems to not work in our case, but I'm sure they can help us without hacking MSBuild.exe.config.

@Tarmil
Copy link
Member

Tarmil commented Dec 7, 2015

I think this doesn't work because it fails to load FSharp.Core to run WS.MSBuild itself, before it even reaches the point where we set up this new appdomain.

Can you try the following:

  • Make sure that you have the latest WebSharper (3.6.2)
  • Remove the MSBuild.exe.config hack
  • Add the following at the top of build/WebSharper.targets, just under the root <Project> element:
  <UsingTask TaskName="WebSharperHandleAssemblyResolve" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
    <ParameterGroup>
      <SearchPath ParameterType="System.String" Required="true" />
    </ParameterGroup>
    <Task>
      <Using Namespace="System" />
      <Using Namespace="System.IO" />
      <Using Namespace="System.Reflection" />
      <Code Type="Fragment" Language="cs">
        <![CDATA[
AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => 
{
  var n = e.Name.Split(',')[0];
  if (n == "FSharp.Core") {
    return Assembly.LoadFrom(Path.Combine(SearchPath, n) + ".dll");
  }
  else return null;
};
]]>
      </Code>
    </Task>
  </UsingTask>
  <Target Name="BeforeBeforeBuild" BeforeTargets="BeforeBuild">
    <WebSharperHandleAssemblyResolve SearchPath="$(MSBuildThisFileDirectory)/../tools/net40" />
  </Target>

It's a bit of an extreme measure, but it should load the FSharp.Core.dll 4.3.0.0 located in the nuget package.

@johannesegger
Copy link
Author

Of course, stupid me, FSharp.Core is needed immediately. I tried adding the UsingTask, but it also fails (see below). I added some Console.WriteLine calls to the C# script so it looks like this:

Console.WriteLine("===== AppDomain name: " + AppDomain.CurrentDomain.FriendlyName);
AppDomain.CurrentDomain.AssemblyResolve += (sender, e) => 
{
  Console.WriteLine("===== Trying to load " + e.Name);
  // Your code
};

With this I got the following output:

Microsoft (R) Build Engine version 14.0.23107.0
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 12/7/2015 8:51:18 PM.
Project "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.sln" on node 1 (Build target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
AppDomain name: MSBuild.exe
Trying to load System.Core
Trying to load System
AppDomain name: MSBuild.exe
Project "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.sln" (1) is building "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website\WkLaufen.Website.fsproj" (2) on node 1 (default targets).
Project "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website\WkLaufen.Website.fsproj" (2) is building "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj" (3) on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
Trying to load WebSharper.MSBuild, Version=3.6.0.0, Culture=neutral, PublicKeyToken=dcd983dec8f76a71
Trying to load WebSharper.MSBuild, Version=3.6.0.0, Culture=neutral, PublicKeyToken=dcd983dec8f76a71
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: The "WebSharperTask" task failed unexpectedly. [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: File name: 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: Server stack trace:  [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Metadata.RemotingTypeCachedData.GetSoapAttributeNoLock() [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Metadata.RemotingCachedData.GetSoapAttribute() [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.InternalRemotingServices.GetCachedSoapAttribute(Object reflectionObject) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.SoapServices.GetXmlTypeForInteropType(Type type, String& xmlType, String& xmlTypeNamespace) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.RemotingServices.DetermineDefaultQualifiedTypeName(Type type) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, ConstructorCallMessage& ctorCallMsg) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Activator.CreateInstance(Type type, Boolean nonPublic) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at WebSharper.MSBuild.WebSharperTask.Execute() [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: Exception rethrown at [0]:  [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at Microsoft.Build.Framework.ITask.Execute() [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: WRN: Assembly binding logging is turned OFF. [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: Note: There is some performance penalty associated with assembly bind failure logging. [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018: To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\packages\WebSharper\build\WebSharper.targets(87,5): error MSB4018:  [D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj]
Done Building Project "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.Extensions\WkLaufen.Website.Extensions.fsproj" (default targets) -- FAILED.
Done Building Project "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website\WkLaufen.Website.fsproj" (default targets) -- FAILED.
Done Building Project "D:\local\Temp\jobs\triggered\publish\j5zhffwn.cfe\website-master\WkLaufen.Website.sln" (Build target(s)) -- FAILED.

Build FAILED.

According to the stack trace it looks as if FSharp.Core is loaded when creating the Settings instance (i.e. before adding the AssemblyResolve handler in the new app domain).

@Tarmil
Copy link
Member

Tarmil commented Dec 8, 2015

Yes it would seem that FSharp.Core is already loaded before we even start to run the task.

I have updated intellifactory/ClientServer.Azure to 3.6 on the develop branch, and I can reproduce this issue with it, so I keep investigating.

@johannesegger
Copy link
Author

I think in my case the problem is that FSharp.Core is loaded immediately when the new AppDomain is created or when the settings object is created. So I think after this line the AssemblyResolve handler should be added (but without using FSharp.Core of course :-) )

EDIT:
Why does it even try to load 4.3.0.0? When creating the AppDomain you use a config file that contains a binding redirect to 4.4.0.0.

@Tarmil
Copy link
Member

Tarmil commented Dec 8, 2015

Yes, I am actually finding out that I was wrong about the issue being when first loading ws.msbuild, and it is actually when loading the appdomain.

I have a fix that is working for me committed on this branch. Can you copy this file to your application's packages/WebSharper/tools/net40/ and try building the application?

@johannesegger
Copy link
Author

Works for me too, thanks for the fast fix. Can you explain what this does and why using the WebSharper40.exe.config file for the new AppDomain doesn't yield in loading FSharp.Core 4.4.0.0?

@Tarmil
Copy link
Member

Tarmil commented Dec 8, 2015

The .config file tells the app domain that when loading FSharp.Core 4.3 it should look for 4.4 instead, but it doesn't say anything about where 4.4 is located. That's what I added in my fix, I force it to load FSharp.Core.dll from the location that is used by the project.

@Tarmil Tarmil closed this as completed in 5d68ce1 Dec 8, 2015
@johannesegger
Copy link
Author

I see, thanks for the explanation. However, I think it doesn't work with all msbuild targets. At least Clean fails in my case because FSharp.Core seems to be not in the ItemInput array. Can you check that please?

@Tarmil
Copy link
Member

Tarmil commented Dec 9, 2015

Indeed, fixing this.

@johannesegger
Copy link
Author

Thanks. I didn't try it, but it won't be able to load the correct FSharp.Core version when doing a Clean, will it?

@Tarmil
Copy link
Member

Tarmil commented Dec 9, 2015

It won't, but it doesn't need to. The reason we need a specific FSharp.Core is so that we can reference the user's assemblies and work on their metadata; but when doing a Clean we don't need to do that, we just delete files.

@johannesegger
Copy link
Author

Ahh I see, thanks.

@johannesegger
Copy link
Author

@Tarmil, I just updated to 3.6.6.225 and the Build task now works as expected, thanks a lot. However the Clean task fails with the same exception as above. Isn't the settings object that is created in the other app domain (see here) also created when executing the Clean task? And doesn't the runtime then try to load FSharp.Core v4.3.0.0 before the assembly resolve handler is registered?

@johannesegger
Copy link
Author

@Tarmil push

@cgravill
Copy link

cgravill commented Feb 5, 2016

I spun up another clean build agent, with a later version of WebSharper (3.6.7.227) and appear to have the same problem:

packages\WebSharper.3.6.7.227\build\WebSharper.targets (60, 5)
The "WebSharperTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'FSharp.Core, Version=4.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Server stack trace:
at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeType type, RuntimeType caType, Boolean inherit)
at System.RuntimeType.GetCustomAttributes(Type attributeType, Boolean inherit)
at System.Runtime.Remoting.Metadata.RemotingTypeCachedData.GetSoapAttributeNoLock()
at System.Runtime.Remoting.Metadata.RemotingCachedData.GetSoapAttribute()
at System.Runtime.Remoting.InternalRemotingServices.GetCachedSoapAttribute(Object reflectionObject)
at System.Runtime.Remoting.SoapServices.GetXmlTypeForInteropType(Type type, String& xmlType, String& xmlTypeNamespace)
at System.Runtime.Remoting.RemotingServices.DetermineDefaultQualifiedTypeName(Type type)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, ConstructorCallMessage& ctorCallMsg)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at WebSharper.MSBuild.WebSharperTask.Execute()
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
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 Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value HKLM\Software\Microsoft\Fusion!EnableLog to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

I can deploy my fix again but it would be great not to have to tweak build agents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants