Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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.

like image 713
Paul_LayLow Avatar asked Jul 31 '18 01:07

Paul_LayLow


People also ask

Where are packages stored in .NET core?

The global-packages folder is where NuGet installs any downloaded package. Each package is fully expanded into a subfolder that matches the package identifier and version number. Projects using the PackageReference format always use packages directly from this folder.

Does dotnet restore NuGet packages?

Description. The dotnet restore command uses NuGet to restore dependencies as well as project-specific tools that are specified in the project file.

Does dotnet pack also build?

By default, dotnet pack builds the project first. If you wish to avoid this behavior, pass the --no-build option. This option is often useful in Continuous Integration (CI) build scenarios where you know the code was previously built.

Does dotnet build do a restore?

You don't have to run dotnet restore because it's run implicitly by all commands that require a restore to occur, such as dotnet new , dotnet build , dotnet run , dotnet test , dotnet publish , and dotnet pack . To disable implicit restore, use the --no-restore option.


1 Answers

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.

like image 175
Shaun Luttin Avatar answered Oct 12 '22 05:10

Shaun Luttin