简体   繁体   中英

distribute simple .net core application with nuget package

I have created simple .net core application which uses a few nuget packages. I want to run it on a different windows 10 machine, where those nuget packages are not installed. When I copy the executable dll and try running it from Powershell console using Dotnet xxx.dll , I am getting the error:

An assembly specified in the application dependencies manifest (XXX.deps.json) was not found:

package: 'CsvTextFieldParser', version: '1.2.1'

path: 'lib/netstandard2.0/CsvTextFieldParser.dll'

As it is simple application, I tried using required nuget package in bin directory and run it. It did not work.

How can I use nuget package in a simple .net core application which I can simple xcopy on other machine and run ?

Did you run dotnet publish before deploying your application? Just running dotnet build is not enough, as the doc for dotnet build points out:

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. This is in contrast to the behavior of the .NET Framework in which building an executable project (an application) produces output that's runnable on any machine where the .NET Framework is installed. To have a similar experience with .NET Core, you need to use the dotnet publish command. For more information, see .NET Core Application Deployment.

So, just run dotnet publish . It will perform the build and restore all dependencies for you, and the output will be fully deployable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM