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.
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.
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).
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.
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.
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.
Thanks in advance.
答案 0 :(得分:2)
blazor.webassembly.js
文件存储在以下划线(_framework)开头的目录中,github的jekyll在部署网站时会忽略该目录。在将名为.nojekyll
的文件添加到存储库的根目录后,仍然出现404错误,这使我困惑了很长时间。原来,我需要对另一个文件进行更改以使网站得以重建,最终纠正了该问题。
我仍然觉得自己在做很多事情,这可能是不好的做法,但这又是另一天。如果有人对此有任何建议,我将为此悬赏。
答案 1 :(得分:1)
看看gh-pages分支的当前状态,我猜您将publish目录中的文件与解决方案中的源文件混合了吗?如果是这样,您只需要从gh-pages分支中清除源文件,以便仅显示从publish目录复制的文件。
除此之外,您现在看来是正确的。