在 Azure 上托管时无法找到位于我的根项目文件夹中的文件 [英] Unable to find files located in my root project folder when hosted on Azure

查看:14
本文介绍了在 Azure 上托管时无法找到位于我的根项目文件夹中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Blazor 客户端 WebAssembly 项目的根项目中查找文件.虽然它在我的计算机上本地执行时有效,但在 Azure 上托管时却不起作用.

I tried to find files located in the root project of my Blazor Client WebAssembly project. While it works when executed locally on my computer, it doesn't work when hosted on Azure.

在本地执行时,我得到了 1

When executed locally, I got 1

在 Azure 上执行时,我得到 0(没有类似的拒绝访问错误)

When executed on Azure, I got 0 (no access denied errors of things like that)

为了更完整,我将需要一些文件来填充初始空白数据库.

To be more complete, I will have some files needed to fill an initial blank database.

如果我无法访问项目文件夹中的文件,那么我将使用 Blob Azure 存储.我想澄清一下,这只是我自己的一个测试项目.

If I cannot access files in the project folder, then I will go for a Blob Azure Storage. I would like to clarify that this is only a test project for myself.

推荐答案

出现此问题的原因是发布时未包含 TextFile.txt 文件.

The reason for this problem is that the TextFile.txt file was not included at the time of publication.

Akos 说的是对的.我正在修改 .csproj 文件以发送我的答案.可以更好地帮助论坛的其他用户.

Akos said is right. I am modifying the .csproj file to send out my answer. Can better help other users of the forum.

您可以在 .csproj 文件中粘贴代码.

You can paste code in your .csproj file.

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <ResolvedFileToPublish Include="TextFile.txt">
      <RelativePath>TextFile.txt</RelativePath>
    </ResolvedFileToPublish>
  </ItemGroup>
</Project>

然后您就可以部署您的应用了.您可以在 D:homesitewwwroot> 下找到 TextFile.txt.

Then you can deploy your app. You can find TextFile.txt under D:homesitewwwroot>.

这篇关于在 Azure 上托管时无法找到位于我的根项目文件夹中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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