简体   繁体   中英

.NET Core 2.1 - dotnet/exe on build, packages are missing

I've been developing on one machine and recently tried to install my application on another PC. I think I've deduced to to the nuget packages not being found since in .NET Core, nuget puts the packages in the local 'Users' folder path.

I initially added the <RunTimeIdentifier> tag to create an exe (which worked on my developer machine). When running the exe on a different machine, the console window will flash very quickly and application stops with no error output (even in Event Viewer).

I also added this tag <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest

in the *.csproj which did not make a difference.

So I tried running dotnet project.dll which gave me this error on the other machine.

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

package: 'Localization.AspNetCore.TagHelpers', version: '0.3.0'

path: 'lib/netstandard1.6.1/Localization.AspNetCore.TagHelpers.dll'

When I 'recreated' the folder structure, lo-and-behold, everything was working. Is there a way on compile/build that those packages are copied to the bin folder and paths reference those instead? Or am I building/compiling wrong?

Also note that thie project was updated from .NET Core 2.0 to 2.1.

Short Answer

It sounds like you want a self-contained deployment . That is what dotnet publish --self-contained --runtime <some-runtime> outputs to the publish directory.

Two Examples

Lets say we have an app at C:\\temp\\temp.csproj , and we want to publish it to two target platforms .

If we publish like this...

dotnet publish --self-contained --runtime win-x86

... the self-contained executable will be here:

C:\dev\temp\bin\Debug\netcoreapp2.1\win-x86\publish\temp.exe

If we publish like this...

dotnet publish --self-contained --runtime ubuntu-x64

... the self-contained executable will be here:

C:\dev\temp\bin\Debug\netcoreapp2.1\ubuntu-x64\publish\temp

If we then copy the entire publish directory to the destination computer, we can execute the temp executable, because all of its dependencies are present.

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