Hirasawa Yui
Hirasawa Yui

Reputation: 1296

Publish .NET Core website as a single executable file

I'm using a "ASP.NET Core with React.js" template in Visual Studio. I've configured publish process to produce a single file. While it does package all the .NET files into one executable, it still generates a separate "ClientApp" folder that contains a build of a React App.

Is there a way to embed everything inside the executable? Like, copy everything inside .zip archive, embed it as a resource and host everything from there.

I am trying to add a UI to a background service. So that a user could open a page in theirs browser and check service status. Frameworks like Electron will not work for me, as the service should be accessible from the local network, not just from the PC it's running on.

Upvotes: 0

Views: 784

Answers (1)

Hirasawa Yui
Hirasawa Yui

Reputation: 1296

Just in case someone will have the same question in the future, I'll post my solution. First of all, I've packed a build of react app into a zip archive. Then, I've included an archive as Embedded Resource into the project. Finally, I've used Lexical.ZipFileProvider as a FileProvider for app.UseStaticFiles. And voila, the thing just works!

Upvotes: 2

Related Questions