Reputation: 1
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). 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'
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.
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.Is there any way to resolve this automatically?
Collect.runtimeconfig.dev.json
:
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\shubhamjain\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\shubhamjain\\.nuget\\packages",
"C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder" ]
}
}
Upvotes: 0
Views: 6045
Reputation: 483
Can you try configuring your json
file with using %username%
parameter. 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 :
{
"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.
Upvotes: 1