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

Sitelets runtime not loading metadata from all needed assemblies on .NET Core #924

Closed
Jand42 opened this issue Mar 13, 2018 · 3 comments
Closed

Comments

@Jand42
Copy link
Member

Jand42 commented Mar 13, 2018

Reproducing issue

If creating a new project with dotnet new websharper-web -lang f# and adding this to Client.Main:

    let event = Event<int>()

Running it locally, a runtime error happens on new FSharpEvent.New() because script link to WebSharper.Control.js is not included as it should be.

Explanation

This is because .NET Core is not copying dlls from packages to output folder (except when publishing or using <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>). WebSharper.Control.dll is an assembly that contains only proxies for .NET types, nothing that is directly referenced. So project output dll will have no assembly references for it (neither direct or indirect).

Compiler knows about it because it is a project reference and compiles fine. But Sitelet runtime won't be able to discover it, and so metadata information for it will not be loaded, so dependency graph will be incoplete, and when discovering needed scripts, WebSharper.Control.js (containing the FSharpEvent among many others) will not be included as a script link in page header.

Proposed solution

WebSharper compiler would add extra assembly references to the output dll targeting any assemblies that are containing WebSharper metadata and are not referenced by the build yet.

@Jand42 Jand42 added the bug label Mar 13, 2018
@Jand42
Copy link
Member Author

Jand42 commented Mar 13, 2018

Workaround: add <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> to project properties.

@Jand42 Jand42 changed the title F# Event not including WS.Control.js link on netcore Sitelets runtime not loading metadata from all needed assemblies on .NET Core Mar 13, 2018
@granicz
Copy link
Member

granicz commented Mar 13, 2018

I would rather fix the underlying cause than introduce an opaque compiler "feature". One such fix would be to output the meta data at build time to the output folder, so the sitelet runtime doesn't have to reconstruct it.

@granicz
Copy link
Member

granicz commented Mar 13, 2018

Andras pointed out this ticket (#664 ) that exists already for this.

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

No branches or pull requests

2 participants