简体   繁体   English

错误:在部署.Net core 2.2 时,找不到应用程序依赖项清单中指定的程序集 Package:Newtonsoft.Json

[英]Error: An assembly specified in the application dependencies manifest not found Package:Newtonsoft.Json when deploying .Net core 2.2

I am deploying a.Net core 2.2 console application using self contained deployment and using some 3rd party libraries like(log4net and Newtonsoft.Json).我正在使用自包含部署并使用一些 3rd 方库(如 log4net 和 Newtonsoft.Json)来部署 a.Net core 2.2 控制台应用程序。 The application is working fine on the system it is developed but not working when deployed to any other system.该应用程序在其开发的系统上运行良好,但在部署到任何其他系统时无法运行。 The below error displays:显示以下错误:

C:\Users\shubhamjain\source\repos\Collect\Collect\bin\Release\netcoreapp2.2\win-x64>Collect.exe

Error: An assembly specified in the application dependencies manifest (Collect.deps.json) was not found: package: 'Newtonsoft.Json', version: '12.0.2' path: 'lib/netstandard1.3/Newtonsoft.Json.dll'错误:未找到应用程序依赖项清单 (Collect.deps.json) 中指定的程序集:package:'Newtonsoft.Json',版本:'12.0.2' 路径:'lib/netstandard1.3/Newtonsoft.Json.dll '

I have tried the below things:我已经尝试过以下事情:

  1. Changing the.Net core version from 2.1 and 2.2从 2.1 和 2.2 更改 .Net 核心版本
  2. changing the version of Newtonsoft.Json from nuget从 nuget 更改 Newtonsoft.Json 的版本
  3. Updating visual studio 2019更新视觉工作室 2019

Nothing worked but when I looked to a file ("Collect.runtimeconfig.dev.json" in path C:\Users\shubhamjain\source\repos\Collect\Collect\bin\Release\netcoreapp2.2\win-x64 ) and change the shubhamjain with the deployed system username, everything works fine.没有任何效果,但是当我查看文件(路径C:\Users\shubhamjain\source\repos\Collect\Collect\bin\Release\netcoreapp2.2\win-x64中的“Collect.runtimeconfig.dev.json”)并更改时使用已部署的系统用户名的shubhamjain ,一切正常。

Now, What I observe that Newtonsoft.Json is depends on file ( .runtimeconfig.dev.json ) and in order to make it work I have to change the username in this file.现在,我观察到Newtonsoft.Json取决于文件( .runtimeconfig.dev.json ),为了使其正常工作,我必须更改此文件中的用户名。

Is there any way to resolve this automatically?有没有办法自动解决这个问题?

Collect.runtimeconfig.dev.json : Collect.runtimeconfig.dev.json

{
  "runtimeOptions": {
     "additionalProbingPaths": [
        "C:\\Users\\shubhamjain\\.dotnet\\store\\|arch|\\|tfm|",
        "C:\\Users\\shubhamjain\\.nuget\\packages",
        "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" ]
  }
}

Can you try configuring your json file with using %username% parameter.您可以尝试使用%username%参数配置您的json文件吗? I am not sure if it is possible to run that way but you can use that parameter in the Command Prompt to get the logged in username.我不确定是否可以以这种方式运行,但您可以在命令提示符中使用该参数来获取登录的用户名。 You can check the link for more detail.您可以查看 链接以获取更多详细信息。

In this case your Collect.runtimeconfig.dev.json will be:在这种情况下,您的Collect.runtimeconfig.dev.json将是:

{
   "runtimeOptions": {
      "additionalProbingPaths": [
         "C:\\Users\\%username%\\.dotnet\\store\\|arch|\\|tfm|",
         "C:\\Users\\%username%\\.nuget\\packages",
         "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" ]
   }
}

Also you can prepare different configuration files for different environments.您还可以为不同的环境准备不同的配置文件。 Maybe this Microsoft Doc could be helpful about that.也许这个 Microsoft Doc可能对此有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Net core VS 测试任务失败并出现错误:未找到应用程序依赖项清单 deps json 中指定的程序集 - Net core VS test task is failing with the error : assembly specified in the application dependencies manifest deps json was not found 迁移到 .NET 6 时,所有测试都没有结论,出现相同的“未找到应用程序依赖项清单中指定的程序集”错误 - All tests are inconclusive with the same "An assembly specified in the application dependencies manifest was not found" error when migrating to .NET 6 未找到应用程序依赖项清单 (project.deps.json) 中指定的程序集 - An assembly specified in the application dependencies manifest (project.deps.json) was not found 无法解决“未找到应用程序依赖项清单中指定的程序集”错误 - Cannot resolve “An assembly specified in the application dependencies manifest was not found” error 未找到应用程序依赖项清单中指定的程序集: - An assembly specified in the application dependencies manifest was not found: 错误:未找到依赖项清单中指定的程序集。 - Error: assembly specified in the dependencies manifest was not found. Newtonsoft.json 汇编包版本不匹配 - Newtonsoft.json assembly package version mismatch 无法加载文件或程序集“ Newtonsoft.Json”或其依赖项之一。 清单定义与程序集引用不匹配。 - Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. manifest definition does not match the assembly reference. 应用程序依赖项清单中指定的程序集 - An assembly specified in the application dependencies manifest 找不到应用程序依赖项清单 (Microsoft.NETCore.App.deps.json) 中指定的程序集 - An assembly specified in the application dependencies manifest (Microsoft.NETCore.App.deps.json) was not found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM