SteveSandersonMS / WebWindow

.NET Core library to open native OS windows containing web UI on Windows, Mac, and Linux. Experimental.
Apache License 2.0
1.98k stars 215 forks source link

PublishSingleFile, including wwwroot? #41

Open dcuccia opened 4 years ago

dcuccia commented 4 years ago

Hi! Would it be feasible to make the web assets an embedded resource and extract on first load? Or even mimic a virtual file system to the browser? Interested in .Net Core single-file publishing for copy-paste portable desktop apps.

sondreb commented 4 years ago

Check out my suggestion in #14

GitMyCode commented 4 years ago

@sondreb your suggestion work for the sample with vue.js but the problem seems that with WebWindow.Blazor when you publish singlefile you get the wwwroot on the side On mac this is the result: image

GitMyCode commented 4 years ago

So okey i made it work with the sample in the .csproj i added ExcludeFromSingleFile="false" for the wwwroot

 <ItemGroup>
    <Content Update="wwwroot\**" ExcludeFromSingleFile="false">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

and of course in the Program.cs

var executingDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location);
ComponentsDesktop.Run<Startup>("My Blazor App", Path.Combine(executingDir,"wwwroot/index.html"));

so now when i publishdotnet publish -r osx-x64 -c release /p:PublishSingleFile=true i get a single executable file and when the content is extracted in the tmp directory i see the wwwroot

image

IvanJosipovic commented 4 years ago

Heads up, you need to be on .Net Core 3.1.200-preview-014977 for ExcludeFromSingleFile="false" to work.