[英]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:我已经尝试过以下事情:
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.