gpt4 book ai didi

visual-studio - 发布到 Azure 不会更新 App_Data 中的文件

转载 作者:行者123 更新时间:2023-12-02 08:01:17 24 4
gpt4 key购买 nike

我的 ASP.Net Core 应用程序在项目根目录下有一个 App_Data 文件夹:

Folders

(我记得 - 我可能是错的 - 我必须在项目中手动创建该文件夹。模板没有自动将其提供给我。)

我的问题是,当我发布项目时,对 App_Data 文件夹中文件的更改不会推送到 Azure。我使用的是 VS Pro 2019。

当我第一次发布该项目时,App_Data 文件夹及其内容被推送到 Azure。但是,正如我所说,更改会被忽略。

这是我不明白的更大问题:显然,App_Data 文件夹很特殊。至少,它在发布配置文件中有一个条目。我看到了很多关于发布(或不发布)这个神奇文件夹中的文件的困难的问题和不知情的答案。但我从未见过任何接近官方文档的内容来谈论这一点魔法。

<小时/>

这是我的发布配置文件:

    <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<ResourceId>/subscriptions/xxx/resourceGroups/Production/providers/Microsoft.Web/sites/xxx</ResourceId>
<ResourceGroup>Production</ResourceGroup>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://xxx.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>xxx</ProjectGuid>
<MSDeployServiceURL>xxx.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>xxx</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>$xxx</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
<InstallAspNetCoreSiteExtension>False</InstallAspNetCoreSiteExtension>
<TargetFramework>netcoreapp2.2</TargetFramework>
<SelfContained>false</SelfContained>
<_IsPortable>true</_IsPortable>
</PropertyGroup>
</Project>

这是我的项目文件(为简洁起见进行了编辑):

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

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<UserSecretsId>aspnet-xxx</UserSecretsId>
<ApplicationInsightsResourceId>/subscriptions/xxx/resourcegroups/xxx/providers/microsoft.insights/components/xxx</ApplicationInsightsResourceId>
<ApplicationInsightsAnnotationResourceId>/subscriptions/xxx/resourcegroups/MyIndigoHealth/providers/microsoft.insights/components/xxx</ApplicationInsightsAnnotationResourceId>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<TypeScriptToolsVersion>3.1</TypeScriptToolsVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.6.1" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" PrivateAssets="All" />
<PackageReference Include="Neleus.DependencyInjection.Extensions" Version="1.0.0" />
</ItemGroup>

<ItemGroup>
<Folder Include="Areas\Identity\Services\" />
</ItemGroup>

<ItemGroup>
<WCFMetadata Include="Connected Services" />
</ItemGroup>

</Project>

最佳答案

据官方documentation :

The Content item list contains files that are published in addition to the build outputs. By default, files matching the pattern wwwroot/** are included in the Content item.

含义(未明确说明)是仅构建输出和 wwwroot/**已发布。

稍后在同一文档中,他们给出了标记示例(没有解释),该标记将其他文件添加到正在发布的文件集中。根据这些示例,我编写了这个标记。将其添加到项目 ( csproj ) 文件会导致 App_Data 中的文件发生更改要发布的文件夹:

<ItemGroup>
<DotnetPublishFiles Include="App_Data/**/*">
<DestinationRelativePath>App_Data/%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
</DotnetPublishFiles>
</ItemGroup>

这仍然留下了一些相关的谜团:

  1. <ExcludeApp_Data> 是什么意思?元真的吗?
  2. 显然,初始发布(来自 Visual Studio)插入了 App_Data文件夹到服务器。当实验和上述引用的文档表明后续发布尝试忽略 App_Data 时,为什么会发生这种情况?文件夹(实际上是 wwwroot 之外的任何文件夹)?

关于visual-studio - 发布到 Azure 不会更新 App_Data 中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55854040/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com