gpt4 book ai didi

blazor-server-side - "TransformAppSettings"任务意外失败

转载 作者:行者123 更新时间:2023-12-04 18:55:38 26 4
gpt4 key购买 nike

我有一个 .NET Core 3 Blazor(服务器端)应用程序,我最近将它从预览版 5 升级到了 .NET Core 3.0.1 预览版 6 版。当我在本地构建和运行它时,它工作正常;但是当尝试将其发布到文件系统文件夹(在框架相关模式下)时,它会引发此错误:

C:\Program Files\dotnet\sdk\3.0.100-preview6-012264\Sdks\Microsoft.NET.Sdk.Publish\targets\TransformTargets\Microsoft.NET.Sdk.Publish.TransformFiles.targets(192,5): Error MSB4018: The "TransformAppSettings" task failed unexpectedly. System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. File name: 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'

at Microsoft.NET.Sdk.Publish.Tasks.AppSettingsTransform.UpdateDestinationConnectionStringEntries(String destinationAppSettingsFilePath, ITaskItem[] destinationConnectionStrings) at Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.TransformAppSettingsInternal() at Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.Execute() at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()



或许值得一提的是,这个错误在预览版 5 版本中并没有发生。此外,我使用 Visual Studio Enterprise 2019 (Windows)。

到目前为止我尝试过的事情:(没有运气)
  • 清洁/重建解决方案
  • 重新安装 .NET Core 3 预览版 6 SDK
  • 添加 Newtonsoft.Json通过 Nuget 打包
  • 在github上搜索社区提出的相关问题
  • .csproj文件
    <Project Sdk="Microsoft.NET.Sdk.Web">

    <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <LangVersion>7.3</LangVersion>
    <AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
    </PropertyGroup>

    <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.1.0" />
    <PackageReference Include="MatBlazor" Version="1.2.0" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
    <PackageReference Include="SqlTableDependency" Version="8.5.3" />
    <PackageReference Include="System.DirectoryServices" Version="4.5.0" />
    <PackageReference Include="System.DirectoryServices.AccountManagement" Version="4.5.0" />
    <PackageReference Include="Telerik.UI.for.Blazor" Version="1.1.1" />
    </ItemGroup>

    <ItemGroup>
    <Folder Include="wwwroot\images\" />
    </ItemGroup>

    <ItemGroup>
    <ProjectReference Include="..\{path to project file}" />
    </ItemGroup>

    </Project>

    最佳答案

    就我而言,我编辑发布配置并关闭数据库 -> 在运行时使用此连接。然后我可以在没有此错误的情况下发布,但是,我必须手动编辑 web.config 并进行以下更改。

    modules="AspNetCorModuleV2"  had to become modules="AspNetCodeModule"

    hostingModel="InProcess" had to become hostingModel="OutOfProcess"

    <environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Development" /> had to become value="Production"

    这些更改已经在我自己的目录 web.config 中,但它们似乎不再在发布中传播。

    关于blazor-server-side - "TransformAppSettings"任务意外失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56996326/

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