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

.NET 8, Web Assembly Deploy Gets "No such file or directory" error on Heroku #192

Open
RobertMeakin opened this issue Jun 24, 2024 · 2 comments

Comments

@RobertMeakin
Copy link

BlazorWebAssembly on net8.0.

I add the correct buildpack and run git push heroku main.

The console shows it building as expected (with the correct .Net version) but in the Heroku, Application Logs, I get the following.

2024-06-24T20:09:30.000000+00:00 app[api]: Build succeeded
2024-06-24T20:12:31.370830+00:00 heroku[web.1]: State changed from crashed to starting
2024-06-24T20:12:39.920961+00:00 heroku[web.1]: Starting process with command `cd /app/heroku_output && ./{ProjectName}`
2024-06-24T20:12:40.549831+00:00 heroku[web.1]: Process exited with status 127
2024-06-24T20:12:40.491794+00:00 app[web.1]: /bin/bash: line 1: ./{ProjectName}: No such file or directory
2024-06-24T20:12:40.574303+00:00 heroku[web.1]: State changed from starting to crashed

Any help is much appreciated.

@jincod
Copy link
Owner

jincod commented Jun 26, 2024

@RobertMeakin
Copy link
Author

RobertMeakin commented Jun 27, 2024

Hi,
This was the problem:

The output for Blazor WASM is static files (wwwroot), not .net core app.
Here

This surprised me because this online tutorial makes no mention of this:
Deploy your C# aspnet core Application free hosting To Heroku Step by Step -2022

My solution was to add a separate node app with express that would serve the static files in wwwroot.
In a separate folder (at the same level as the folder containing the web assembly project):

npm init -y
npm install express

node_server/index.js :

  const express = require('express');
  const path = require('path');
  const app = express();

  app.use(express.static(path.join(__dirname, '../wwwroot')));

  const PORT = process.env.PORT || 3000;
  app.listen(PORT, () => {
    console.log(`Server is running on http://localhost:${PORT}`);
  });

Procfile:
web: node node_server/index.js

Then write a bash script that would take care of running dotnet publish -c Release -o release, copy the wwwroot folder to the express app and push to heroku.

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

2 participants