Visual Studio无法发布 [英] Visual Studio cannot publish

查看:153
本文介绍了Visual Studio无法发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试了一个新项目,只是为了确认我没有犯任何错误,但是Visual Studio 2019不会发布任何点网核心项目.下面是我遇到的错误...任何帮助将不胜感激...

I tried this with a new project just to confirm that I have not made any errors, but Visual Studio 2019 won't publish any dot net core project. Below is the error I am getting... Any help would be much appreciated...

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

Severity Code Description Project File Line Suppression State Error 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()

WRN:程序集绑定日志记录已关闭. 若要启用程序集绑定失败日志记录,请将注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog](DWORD)设置为1. 注意:与程序集绑定失败日志记录有一些性能上的损失. 要关闭此功能,请删除注册表值[HKLM \ Software \ Microsoft \ Fusion!EnableLog]. ProjectNameX 0

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog]. ProjectNameX 0

这是我的项目文件

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

  <PropertyGroup>
      <TargetFramework>netcoreapp3.0</TargetFramework>
      <UserSecretsId>aspnet-ProjectNameX-A0D4A38F-C3FA-4FD3-8EBC-0F2201FBCD57</UserSecretsId>
      <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
      <DockerfileContext>..\..\..</DockerfileContext>
  </PropertyGroup>


  <ItemGroup>
      <PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="3.0.0-preview6.19307.2" />
      <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.0.0-preview6.19307.2" />
      <PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="3.0.0-preview6.19307.2" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0-preview6.19304.10" />
      <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.0.0-preview6.19304.10" />
      <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.7.12" />
  </ItemGroup>

在深入Visual Studio文件夹时,我发现了这个...

While digging into visual studio folders, I found this...

推荐答案

该错误与您的项目无关.错误消息很明显"表明Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.TransformAppSettingsInternal()试图访问Newtonsoft.Json.显然这不是您的代码.

The error has nothing to do with your project. The error message "clearly" says that Microsoft.NET.Sdk.Publish.Tasks.TransformAppSettings.TransformAppSettingsInternal() tried to access Newtonsoft.Json. This is obviously not your code.

我发现这很奇怪,因为Microsoft.NET.Sdk.Publish.Tasks.dllNewtonsoft.Json.dll位于同一目录中(请检查c:\ program files \ dotnet \ sdk),并且应该针对出厂时的相同版本进行编译.您可以使用ILSpy之类的东西进行确认,以查看Newtonsoft.Json的程序集版本是什么以及发布任务dll具有哪个程序集引用.您还可以使用Fusion Logs更好地了解.NET用于尝试加载dll的路径和dll,以及为何未使用具有匹配文件名的任何dll.但是我不会在这里写关于使用融合日志的教程.

I find this very strange, as Microsoft.NET.Sdk.Publish.Tasks.dll exists in the same directory as Newtonsoft.Json.dll (check c:\program files\dotnet\sdk), and it should have been compiled against the same version that ships. You can confirm using something like ILSpy to see what the assembly version of Newtonsoft.Json is and what assembly reference the publish tasks dll has. You can also better understand the paths and dlls that .NET used to try to load the dll, and why any dll with a matching filename was not used, using Fusion Logs. But I'm not going to write a tutorial on using Fusion Logs here.

无论如何,了解它发生的原因并不能帮助您解决它.您真正可以做的就是确保使用的是最新的SDK,如果没有,请安装最新版本,如果问题仍然存在,请使用Visual Studio报告问题"工具让.NET Core团队了解这一点.

In any case, understanding why it's happening won't help you solve it. All you can really do is make sure you're using the latest SDK, install the newest version if not, and if the problem still exists using the Visual Studio "report a problem" tool to let the .NET Core team know about this.

这篇关于Visual Studio无法发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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