2

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:

enter image description here

Publish settings:

enter image description here

  • Do you have a package reference to that in your csproj? – Chris Pratt Aug 19 '19 at 14:17
  • @ChrisPratt - I have a dependency on Microsoft.AspNetCore.App which then references the WebApi.Client library. That's under 'SDK', I don't have a NuGet reference on it or anything. –  Aug 19 '19 at 14:19
  • can you show how is your reference made ? just a part of .csproj – Lorenzo Isidori Aug 19 '19 at 14:50
  • 1
    so your application run successfully if you use the non self contained deploy? – Lorenzo Isidori Aug 19 '19 at 15:13
  • It runs fine on my dev machine. On the target environment I get the same results whether from the self contained or framework dependent, and that is that it won't run because it's missing that DLL. I ideally want to avoid shipping this DLL separately or having to install it outside of my app, I want this app to be delivered in it's entirety (inc. supporting frameworks). Ideally. –  Aug 19 '19 at 15:14
  • But I don't see Microsoft.AspNet.WebApi.Client among your references. Am I missing something? – Lorenzo Isidori Aug 19 '19 at 15:22
  • AspNetCore.App references it –  Aug 19 '19 at 15:40
  • @JᴀʏMᴇᴇ Can you show your publish settings? Are you publishing it with self contained and non framework dependent settings? – Mohsin Mehmood Aug 19 '19 at 15:43
  • What directory are you copying? Are you copying `Release/netcoreapp2.2/publish/win-x64` or something else? – omajid Aug 19 '19 at 16:38
  • I've tried copying ever DIR that includes the exe, none of the exes run. –  Aug 19 '19 at 16:40
  • @MohsinMehmood - I'm publishing as self contained, I tried 'portable' but then switched to win 64, none of it's working. –  Aug 19 '19 at 16:40
  • Copy `bin/Release/netcoreapp2.2/win-x64/` and run the exe contained inside that on the target machine. – omajid Aug 19 '19 at 16:41
  • i tried that Omair it's still saying missing dll. –  Aug 19 '19 at 16:42
  • @JᴀʏMᴇᴇ - Please add a screenshot of your publish settings. – Mohsin Mehmood Aug 19 '19 at 17:12

1 Answers1

1

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:

Published console application with Microsoft.AspNetCore.App metapackage only

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.

Published console application with direct reference to Microsoft.AspNet.WebApi.Client


I hope it would help.

Vlad DX
  • 4,200
  • 19
  • 28
  • 1
    Thanks a lot Vladimir! I rewarded the bounty as it was about to expire. I just tried this, but no additional DLLs were created in the publish folder. Which folder should I be looking at after publish? There are 390 files in the publish dir. –  Aug 27 '19 at 08:35
  • 390 files and no `Newtonsoft.Json.Bson.dll` and others? – Vlad DX Aug 27 '19 at 10:31
  • @JᴀʏMᴇᴇ Could you provide the simplest reproducible example of the project? – Vlad DX Aug 27 '19 at 10:40