An assembly specified in the application dependencies manifest - c#

I wrote a .net core console application on mac and it's working fine. Then I made a build for ubuntu by using
dotnet build --runtime ubuntu.16.04-x64
the result was:
MyAppName.Server MyAppName.Server.runtimeconfig.dev.json
MyAppName.Server.deps.json MyAppName.Server.runtimeconfig.json
MyAppName.Server.dll libhostfxr.so
MyAppName.Server.pdb libhostpolicy.so
I copied these files on my linux server and run the following command
dotnet MyAppName.Server.dll
And now I getting
Error:
An assembly specified in the application dependencies manifest (MyAppName.Server.deps.json) was not found:
package: 'Ether.Network', version: '2.0.1'
path: 'lib/netstandard1.3/Ether.Network.dll'
Ether.Network is the only package that I using.

From dotnet build's documentation:
If the project has third-party dependencies, such as libraries from NuGet, they're resolved from the NuGet cache and aren't available with the project's built output. With that in mind, the product of dotnet build isn't ready to be transferred to another machine to run.
You want dotnet publish instead:
The dotnet publish command's output is ready for deployment to a hosting system (for example, a server, PC, Mac, laptop) for execution and is the only officially supported way to prepare the application for deployment.

Related

Microsoft.AspNetCore.Server.Kestrel.Transport.Quic - error after NET6 migration

I have already updated my app (asp.net API) from NetCore3.1 to Net6. There was no breaking changes. To build my app I use command
dotnet publish --runtime win-x64 --self-contained -c release -o build
When I run app on local env everything works fine, but when I copy package into CICD server I get error when app is starting
Could not load file or assembly
'Microsoft.AspNetCore.Server.Kestrel.Transport.Quic, Version=6.0.0.0, PublicKey=adb9...'. The system cannot find the file specified.
There is such dll in bin folder, but different version (ver 6.0.4 and public key started with f9ae).
I don't understand why correct version isn't present in build folder (I publish as self-contained).
How can I check where is such DLL located on my local environment (can I log it)? What should I do to finish migration to NET6?
I find answer, on server there was old app.runtime.json which made mess with dependencies.
Please remember to update [app].runtime.json when you migrate from NetCore3.1 to NET6 :)

Self-contained .net core 3.1 app giving hostxfr.dll not found

I have a win-x64 app which is c++ calling a C++/CLI .Net Core DLL which is in turn calling a C# .Net core 3.1 DLL. It works fine on my development computer.
I've setup all of the projects to copy all of the depenencies and the C# project post build step has
dotnet restore -r win-x64
dotnet publish "$(ProjectFileName)" -r win-x64 --no-build -c $(ConfigurationName) -o $(OutDir) --no-restore -p:PublishReadyToRun=true --self-contained true
I copied the EXE and all of the DLLs to the target machine and they're all in one directory (including the hostxfr.dll file that its complaining it can't find). When I run it with set COREHOST_TRACE=1 I get
Can't open the SDK installed location registry key, result: 0x2
Using global installation location [C:\Program Files\dotnet] as runtime location
.
A fatal error occurred. The required library hostfxr.dll could not be found.
If this is a self-contained application, that library should exist in [].
If this is a framework-dependent application, install the runtime in the global
location [C:\Program Files\dotnet] or use the DOTNET_ROOT environment variable t
o specify the runtime location or register the runtime location in [HKLM\SOFTWAR
E\dotnet\Setup\InstalledVersions\x64\InstallLocation].
The .NET Core runtime can be found at:
- https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x64&rid=win81
-x64
Failed to start the .NET Core runtime. Error code -2147450749
I tried setting DOTNET_ROOT=the target dir name -- that didn't help.
I tried removing the ready-to-run flag and rebuilding - that didn't help either.
What magic incantation do I need to fix this?

how to include nuget package on raspberry pi without internet?

is there are way to use nuget Packages with dotnet on a raspberry PI without Internet?
I have installed dotnet SDK on a raspberry PI.
I have also installed nuget CLI on raspberry PI.
I am using nuget CLI with mono.
I followed the second Answer from this Question :
dotnet add package with local package file
I created a feed from package. When I enter:
dotnet add package MyPackage -s ./packages
I get this as output:
Writing /tmp/tmp3Ax5wm.tmp
info: Adding PackageRefernce for package 'system.device.gpio' into project '/home/pi/ws/dotnet/testapp.csproject'.
info: Restoring packages for /home/pi/ws/dotnet/testapp.csproject...
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error: Resource temporarily unavailable
Somebody has an idea? I coppied the .nupkg with a usb stick on the raspberry pi.
Maybe running a nuget Server on the raspberry pi and push it the local server and install it from there? For example https://github.com/ai-traders/liget ?
Is there a easy way to solve the problem?
I would recommend you add directory with all your packages you need as a local file share. Then you just need to define that local file share as a source in a nuget.config file at the root of your app. Then when you run the command it will check that file share for the package. Much easier to implement then having to host a nuget server.
Here are some docs on it: https://learn.microsoft.com/en-us/nuget/hosting-packages/local-feeds
I would recommend you to not use the .Net core SDK on your raspberry but .Net core Runtime then you can develope your .Net core app on a real PC and publish to a publish folder. During publish .Net core restores all DLLs of nuget packages into the publish folder. After that you can easily copy paste your publish folder on your raspberry and start your app with dotnet yourpath/yourApplicationName.dll in Linux-cli or execute for windows the application.exe in the publish folder.

assembly specified in the dependencies manifest was not found 'Microsoft.ApplicationInsights.AspNetCore'

I want to publish .net core 2.0 project in windows 10 for ubuntu16.04:
dotnet build
dotnet publish -c Release -r ubuntu.16.04-x64
after build and pulish project and run it at ubuntu, i see this error :
Error: assembly specified in the dependencies manifest was not found
‘Microsoft.ApplicationInsights.AspNetCore’, version: 'x.x', path:
‘lib/netstandard1.3/Microsoft.ApplicationInsights.AspNetCore.dll’
I also tested this solution:
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
but not solved :(
While I did not have this problem in .net core 1
Are you running it on a mahine which have only .netcore runtime installed?
In this case, you will need to install aspnetcore runtime store. It is included in the dotnet sdk, but not in the default runtime.
Depending on how you installed the runtime, you will either have to install it via package manager (apt-get install aspnetcore-store-2.0.0) or download tarball and install it in your dotnet folder as stated in below link:
See missing runtime store error on linux with .NET Core 2.0 runtime only

.NET core CLI -> run ERROR

I have a little bit of problem with dotnet core CLI.
When I am in a project directory and type:
dotnet restore
dotnet publish
It creates published version of my code. And it says that my project is in **PROJECT NAME** -> /Users/**NAME**/hwapp/bin/Debug/netcoreapp1.1/hwapp.dll.
After typing dotnet run it runs my code but when I step to that directory with my dll file compiled and run that dll with dotnet run command i get the following error.
Can some please explain me what I am doing wrong?
dotnet run is a development tool meant to run msbuild projects (e.g. csproj), not execute built applications.
Use dotnet hwapp.dll to run a built application.

Categories

Resources