适当地将blazor项目发布/部署到github页面 [英] Properly publishing/deploying a blazor project to github pages

查看:445
本文介绍了适当地将blazor项目发布/部署到github页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先我要说我肯定比我的薪水高一点.我将尽力描述这个问题,并使其最容易回答.

I'll start this by saying I'm definitely working a bit above my paygrade here. I'll be doing my best to describe this problem and make it easiest to answer.

我已经在Visual Studio中创建了一个Blazor项目,该项目已连接到GitHub存储库中的此处 gh-pages分支.在阅读Blazor的托管和部署指南此处后,我在Visual中发布了该项目. Studio,然后将/bin/Release/netstandard2.0/publish/ChargeLearning/dist文件夹中的文件复制到存储库的根目录,从而得到具有以下文件结构的存储库:

I've made a Blazor project in Visual Studio and this is connected to the GitHub repository here in the gh-pages branch. After reading Blazor's hosting and deploying guide here, I published the project in Visual Studio and copied the files in the /bin/Release/netstandard2.0/publish/ChargeLearning/dist folder to the root of the repository resulting in a repository with this file structure:

ChargeLearning
    ChargeLearning
    _content
    _framework
    css
    sample-data
    ChargeLearning.sln
    index.html

在这一点上,我认为不好的做法已经深陷其中.

At this point I think am already neck-deep in bad practice.

无论如何,尝试加载大多数文件的 index.html 会在控制台中导致404错误在html标头中,例如bootstrap(如blazor部署指南所警告).

Regardless, attempting to load the index.html results in 404 errors in the console for most of the files in the html header like bootstrap (as the blazor deploying guide warned).

因此,我尽可能地按照说明进行操作,尝试实现指南中链接的gh页的页面应用(SPA)修复.

So I followed the instructions there as best as I could, attempting to implement this single page app (SPA) fix for gh-pages linked in the guide.

我现在在加载页面时将404.html文件添加到ChargeLearning存储库中,该页面仅显示blazor.webassembly.js文件的一个404错误.

I added the 404.html file to the ChargeLearning repository now when I load the page it displays just one 404 error, for the blazor.webassembly.js file.

然后,我将SPA修复程序中的重定向脚本添加到我的willthamic.github.io 存储库当我打开直接url blazor.webassembly.js文件时,似乎可以正确重定向但是github显示了我的主页,我现在意识到它已经被严重破坏了,现在图像无法加载.

I then add the redirect script from the SPA fix to my willthamic.github.io repository which when I open the direct url to the blazor.webassembly.js file seems to redirect properly but github shows my home page and I now realize that it has been severely mangled and now images aren't loading.

我觉得我在这里做错了很多事情,这使得很难一次隔离并解决单个问题.

I feel like I am doing a lot of things wrong here which makes it difficult to isolate and solve a single problem at once.

如果您对如何正确部署此工具有具体建议,或者在如何做一些我想尝试做的事情上有一些小建议,我将不胜感激.

If you have specific advice on how to properly deploy this or even small things on how to do what I'm trying to do a little more properly I would greatly appreciate it.

谢谢.

推荐答案

blazor.webassembly.js文件存储在以下划线(_framework)开头的目录中,github的jekyll在部署网站时会忽略该目录.在将一个名为.nojekyll的文件添加到存储库的根目录之后,仍然出现404错误,这让我很困惑.原来,我需要对另一个文件进行更改以使网站得以重建,最终解决了该问题.

The blazor.webassembly.js file was stored in a directory beginning with an underscore (_framework), which github's jekyll ignores when deploying the website. After adding a file named .nojekyll to the root of the repository there was still a 404 error which confused me for a very long time. It then turned out I needed to make a change to another file to cause the website to be rebuilt, finally correcting the issue.

我仍然觉得自己在做很多事情,这可能是不好的做法,但这又是另一天.如果有人对此有任何建议,我将给予赏金.

I still feel as though I am doing many things which could be bad practice, but that is for another day. If someone has any advice relating to that I will award the bounty for it.

这篇关于适当地将blazor项目发布/部署到github页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆