3

I know that we are able to publish .Net Core 3.x console applications as a self-contained, singlefile. But is it possible to publish web application as a single file?

I tried to use

<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishReadyToRun>true</PublishReadyToRun>
<PublishSingleFile>true</PublishSingleFile>

But after publishing I've got the error ANCM Application DLL Not Found. My application is on .Net Core 3.1.1.

How can I do that?

Mohammad Taherian
  • 1,622
  • 1
  • 15
  • 34
  • Have you tried publishing asp.net as self contained deployment, which will put all the dependency file for run time into one folder. Then using command line in this folder run `dotnet publish -r win-x64 -c Release /p:PublishSingleFile=true` – Clint Jan 30 '20 at 17:04
  • @Clint As I mentioned, I've set `true`. But is it important to publish it on command line instead of Visual Studio 2019? – Mohammad Taherian Jan 30 '20 at 22:00
  • @Clint I also did it but still getting same error. – Mohammad Taherian Jan 30 '20 at 22:16
  • To address your question to @Clint, and as discussed on a [similar thread](https://stackoverflow.com/questions/50703578/publish-net-core-app-as-portable-executable), you should only need _either_ `` _or_ `/p:PublishSingleFile=true`; as you suspected, those are redundant. Note that you _shouldn't_ require the `` element, as that's implied by ``—though I also don't think it will hurt anything. – Jeremy Caney Mar 24 '20 at 18:29
  • I should also note that the [original design document for single file publishing](https://github.com/dotnet/designs/blob/master/accepted/2020/single-file/design_3_0.md) may be a useful reference here. I bring this up because most references to this document point to the old location, so it's currently difficult to find if you don't know where to look. – Jeremy Caney Mar 24 '20 at 19:38
  • @JeremyCaney Thank you for your help. I made your changes and I just got this error `HTTP Error 500.38 - ANCM Application DLL Not Found` – Mohammad Taherian Mar 24 '20 at 20:27

1 Answers1

0

You should edit your webconfig to look like

 <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
      </handlers>

instead of

 <handlers>
        <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
      </handlers>
mko
  • 6,638
  • 12
  • 67
  • 118