"TransformAppSettings"任务意外失败 [英] The "TransformAppSettings" task failed unexpectedly

查看:192
本文介绍了"TransformAppSettings"任务意外失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a .NET Core 3 Blazor (server side) application which I recently upgraded to .NET Core 3.0.1 preview 6 version from the preview 5 version. When I build and run it locally, it works fine; but when trying to publish it to a file system folder (in Framework-Dependent mode), it throws this error:

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 ):错误MSB4018:"TransformAppSettings"任务意外失败. System.IO.FileNotFoundException:无法加载文件或程序集"Newtonsoft.Json,版本= 10.0.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed"或其依赖项之一.该系统找不到指定的文件. 文件名:"Newtonsoft.Json,版本= 10.0.0.0,文化=中性,PublicKeyToken = 30ad4fe6b2a6aeed"

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'

在Microsoft.NET.Sdk.Publish.Tasks.AppSettingsTransform.UpdateDestinationConnectionStringEntries(String destinationAppSettingsFilePath,ITaskItem [] destinationConnectionStrings)中的

在Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.TransformAppSettingsInternal() 在Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.Execute() 在Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() 在Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()

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).

It's perhaps worth mentioning that this error didn't occur in the preview 5 version. Also, I use Visual Studio Enterprise 2019 (Windows).

  • 清洁/重建解决方案
  • 重新安装.NET Core 3预览版6 SDK
  • 通过Nuget添加Newtonsoft.Json
  • 在github上搜索社区提出的相关问题
  • Clean/Rebuild solution
  • Reinstall .NET Core 3 preview 6 SDK
  • Add Newtonsoft.Json package via Nuget
  • Search for related issues raised by the community on github
<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并进行以下更改.

In my case, I edit the publish configuration and turned off the Database -> Use this connection at runtime. Then I could publish without this error, however, I had to manually edit the web.config and make the following changes.

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中,但似乎不再在发布中传播了.

These changes were already in my own directories web.config, but they didn't seem to get propagated in the publish anymore.

这篇关于"TransformAppSettings"任务意外失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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