I was under the impression self-contained core deployments came with everything they needed as part of the build/release, but I've shipped the contents of my release folder to the target environment and I get the following error:
An assembly specified in the application dependencies manifest was not found: package: 'Microsoft.AspNet'WebApi.Client', version: '5.2.6' path: 'lib/netstandard2.0/System.Net.Http.Formatting.dll'
I've tried adding the following attribute to the project XML but I still can't see that DLL in the release directory:
<PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
Just to be clear, I've tried running the exe (which is when I get this error) from the publish directory and the winx64 directory (which I'm surprised to find is a lot smaller in size?)
I know probably one of the solutions here would be to ensure I install a framework/dependency on the target environment, but I really want to avoid doing that since I'd like this app to be truly self-contained.
Project XML:
Publish settings:
I believe the issue is related to using the Microsoft.AspNetCore.App
metapackage only.
When you use the Microsoft.AspNetCore.App metapackage, no assets from the referenced ASP.NET Core NuGet packages are deployed with the application—the ASP.NET Core shared framework contains these assets.
https://learn.microsoft.com/en-us/aspnet/core/fundamentals/metapackage-app?view=aspnetcore-2.2
It's not publishing any transient dependencies. But if you add the NuGet package Microsoft.AspNet.WebApi.Client
directly to your project, it should work properly.
Let me give you a simple example. I'm using Visual Studio 2019 and will create simple console application.
Example 1
I've just created a fresh console application. The project file looks like that.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.App" />
<!-- This is a metapackage ^^^ -->
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\PublishProfiles\" />
</ItemGroup>
</Project>
When I publish the project, the output directory looks like that:
Example 2
Then I update the project by adding a reference to the NuGet package Microsoft.AspNet.WebApi.Client
. Now project file has an additional line:
<ItemGroup>
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<!-- Direct reference to the package ^^^ -->
<PackageReference Include="Microsoft.NETCore.App" />
</ItemGroup>
There are transient dependencies for Microsoft.AspNet.WebApi.Client
package are included.
I hope it would help.