Home > Net >  Blazor 6.0 Publish doesn't produce the index.html file
Blazor 6.0 Publish doesn't produce the index.html file

Time:12-31

I have written something using blazor wasm and am trying to publish the project on Github Pages. However, when I try the dotnet publish -c Release command, it only produces a list of files as followed:

  1. wwwroot folder containing all the static sources but without an index.html file
  2. the .json, .dll, web.config and an .exe file.

Generally, if I want to upload the page to Github Pages, I would need an index.html file which would be automatically generated by blazor publish I believe, but there isnt.

How can I solve this issue? Thanks a lot!

CodePudding user response:

Your project's wwwroot folder needs to contain an index.html file. That's what gets initially served to the browser and is the root of all other file requests (images, dlls, etc). Unlike a web.config file (used for IIS), this file is NOT generated for you - you maintain the file.

You can always create a new Blazor WebAssembly project to get an example of what the index.html file should look like, but this is the current template file at time of writing.

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>BlazorApp1</title>
    <base href="/" />
    <link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
    <link href="css/app.css" rel="stylesheet" />
    <link rel="icon" type="image/png" href="favicon.png" />
    <link href="BlazorApp1.styles.css" rel="stylesheet" />
</head>

<body>
    <div id="app">
        <svg >
            <circle r="40%" cx="50%" cy="50%" />
            <circle r="40%" cx="50%" cy="50%" />
        </svg>
        <div ></div>
    </div>

    <div id="blazor-error-ui">
        An unhandled error has occurred.
        <a href="" >Reload</a>
        <a >           
  • Related