dotnet / fsharp

The F# compiler, F# core library, F# language service, and F# tooling integration for Visual Studio
https://dotnet.microsoft.com/languages/fsharp
MIT License
3.9k stars 782 forks source link

Blazor WebAssembly publish problem #12470

Closed krauthaufen closed 2 years ago

krauthaufen commented 2 years ago

When publishing a blazor-wasm project (dotnet publish and Visual Studio 2022 Preview 7.0) that references Microsoft.AspNetCore.Components.WebAssembly the output-folder does not contain the dll and a simple static HTTP-server (nginx in my case) can't serve the app. Also publishing to Azure doesn't work.

Using nginx i get: image

I originally submitted the issue in dotnet but they seem to think it's F# specific.

Any Help would be greatly appreciated.

Here's a small repro for the problem

Expected behavior

publish should include all relevant DLLs

Actual behavior

doesn't

Known workarounds

none

Related information

dotnet 6.0

vzarytovskii commented 2 years ago

It looks like a Paket problem, if I have just normal project file with:

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
    <OutputType>Exe</OutputType>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Program.fs" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Update="FSharp.Core" Version="6.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.2.21480.10" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.2.21480.10" />
  </ItemGroup>
</Project>

Then publish it:

PS C:\Users\vlza\code\BlazorPublishProblem> dotnet publish -c Release
Microsoft (R) Build Engine version 17.1.0-preview-21572-15+513f59ce4 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  Restored C:\Users\vlza\code\BlazorPublishProblem\BlazorPublishProblem\BlazorPublishProblem.fsproj (in 335 ms).
  You are using a preview version of .NET. See: https://aka.ms/dotnet-core-preview
  BlazorPublishProblem -> C:\Users\vlza\code\BlazorPublishProblem\BlazorPublishProblem\bin\Release\net6.0\BlazorPublishProblem.dll
  BlazorPublishProblem (Blazor output) -> C:\Users\vlza\code\BlazorPublishProblem\BlazorPublishProblem\bin\Release\net6.0\wwwroot
  Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Compressing Blazor WebAssembly publish artifacts. This may take a while...
  BlazorPublishProblem -> C:\Users\vlza\code\BlazorPublishProblem\BlazorPublishProblem\bin\Release\net6.0\publish\

I can see the dll in the published _framework directory:

PS C:\Users\vlza\code\BlazorPublishProblem> ls .\BlazorPublishProblem\bin\Release\net6.0\publish\wwwroot\_framework\Microsoft.AspNetCore.*

    Directory: C:\Users\vlza\code\BlazorPublishProblem\BlazorPublishProblem\bin\Release\net6.0\publish\wwwroot\_framework

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a---          11/30/2021  4:12 PM          36352 Microsoft.AspNetCore.Components.dll
-a---          11/30/2021  4:12 PM          14164 Microsoft.AspNetCore.Components.dll.br
-a---          11/30/2021  4:12 PM          16204 Microsoft.AspNetCore.Components.dll.gz
-a---          11/30/2021  4:12 PM           8704 Microsoft.AspNetCore.Components.Web.dll
-a---          11/30/2021  4:12 PM           3466 Microsoft.AspNetCore.Components.Web.dll.br
-a---          11/30/2021  4:12 PM           3893 Microsoft.AspNetCore.Components.Web.dll.gz
-a---          11/30/2021  4:12 PM          30720 Microsoft.AspNetCore.Components.WebAssembly.dll
-a---          11/30/2021  4:12 PM          12405 Microsoft.AspNetCore.Components.WebAssembly.dll.br
-a---          11/30/2021  4:12 PM          14116 Microsoft.AspNetCore.Components.WebAssembly.dll.gz

And if I run it:

PS C:\Users\vlza\code\BlazorPublishProblem> cd .\BlazorPublishProblem\bin\Release\net6.0\publish\wwwroot\ && python -m http.server
Serving HTTP on :: port 8000 (http://[::]:8000/) ...

I can see: image

So, I presume, that publishing target doesn't know about PackageReference added by Paket?

krauthaufen commented 2 years ago

Okay, thanks for the hint. I just found https://github.com/fsprojects/Paket/issues/2887 and https://github.com/fsprojects/Paket/issues/3999 which sadly seem to be related and sadly rather inactive.

I'll try to revive the discussion there..

vzarytovskii commented 2 years ago

Okay, thanks for the hint. I just found fsprojects/Paket#2887 and fsprojects/Paket#3999 which sadly seem to be related and sadly rather inactive.

I'll try to revive the discussion there..

Yeah, those issues look relevant. I will close this one meanwhile, if you're okay with it.

Please feel free ping me here if it needs to be reopened.