Azure DevOps, Scrum, & .NET Software Leadership and Consulting Services

Free course! Predicting the Future, Estimating, and Running Your Projects with Flow Metrics

Force ‘dotnet publish’ to publish dependencies using PublishWithAspNetCoreTargetManifest

I ran into a problem today doing an automated build for a ASP.NET Core 2 project and then trying to deploy the output.  From the command line, I ran “dotnet publish -o c:\temp\presidents” to build and publish the code for my ASP.NET Core web application.  Then I went to the directory that I just published to (‘c:\temp\presidents’) and tried to run it using “dotnet Benday.Presidents.WebUi.dll”.

At this point, I’d expect that it would just run because I’d just done a ‘publish’ and that publish is supposed to create a deployable version of my ASP.NET Core app.  Right?  I mean that’s what I think of when I do a publish.

The answer: Nope.  More precisely: Nope nope nope and more nope with an extra side of nope sauce for dipping and furthermore nnnnnnope.

Here’s what I got.

An assembly specified in the application dependencies manifest (Benday.Presidents.WebUi.deps.json) was not found:
package: ‘Microsoft.AspNetCore.Mvc.Abstractions’, version: ‘2.0.2’
path: ‘lib/netstandard2.0/Microsoft.AspNetCore.Mvc.Abstractions.dll’
This assembly was expected to be in the local runtime store as the application was published using the following target manifest files:

The Heavy-Handed Fix

Hunting around on the internet(s), I saw a bunch of people mentioning that it works if you add <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest> to your *.csproj file.

I added that and re-ran my dotnet publish and it fixed it.  All the required DLLs got published and my “dotnet Benday.Presidents.WebUi.dll” command ran the web app successfully.

But this seemed a little heavy-handed.

The More Lightweight, DevOps-Friendly Fix

Thanks to this thread on StackOverflow and a comment from Nate McMaster, there’s an easier way to do this that doesn’t require editing your csproj file.  Turns out that there’s an undocumented /property command line option for “dotnet publish” that lets you pass msbuild variables in.  Supply the following /property value and it causes dotnet publish to publish all the dependencies.

dotnet publish -o c:\temp\presidents /property:PublishWithAspNetCoreTargetManifest=false

Now why do I think that this is more DevOps-friendly?  Well, when I’m doing a DevOps release pipeline, I want to build one time and then be done with it.  I want everything to be packaged up into something that I can easily deploy and I don’t want my environment-specific releases to have to worry about finding and resolving dependencies.  Adding this /property:PublishWithAspNetCoreTargetManifest=false to my automated build gives me a nice clean easily-deployable output from my build.

PublishWithAspNetCoreTargetManifest With TFS Builds and VSTS Builds

If you create a build definition in Team Foundation Server (TFS) or Visual Studio Team Services (VSTS) for an ASP.NET Core project, the default definition template basically does the same thing as what you’d do on the command prompt.  It does a “dotnet restore”, “dotnet build”, “dotnet test”, and then a “dotnet publish”.  The last step is to do a “Publish Artifact” operation that publishes the output of the builds to TFS/VSTS where it can later be deployed using a Release Definition.

The build steps for an ASP.NET Core build in TFS/VSTS

The problem here is that the artifacts that get published up is going to be missing all the dependent DLLs.  Exactly the same problem that I had on the command line.

To fix this problem in TFS/VSTS, you need to plug in the PublishWithAspNetCoreTargetManifest option into your build.

First, click on the Publish step.  Next, locate the Arguments field and add /property:PublishWithAspNetCoreTargetManifest=false to the end of that field.

Add /property:PublishWithAspNetCoreTargetManifest=false to the dotnet publish step

Now you can run your build and you’ll get all the required files.


There’s something odd in the way that the ‘dotnet publish’ command works with ASP.NET Core applications.  Whether it’s by design or whether it’s a bug, I’m not sure.  There are two workarounds: 1) Edit the project file (csproj) for your web project and add an msbuild property for  PublishWithAspNetCoreTargetManifest that’s set to false or 2) supply the /property:PublishWithAspNetCoreTargetManifest=false to your dotnet publish commands.

I hope this helps.



— Has DevOps got you down?  Need help with your automated builds and releases?  Trying to figure out how to work DevOps thinking into your existing Agile/Scrum process?  We can help.  Drop us a line at  


13 responses to “Force ‘dotnet publish’ to publish dependencies using PublishWithAspNetCoreTargetManifest”

  1. Kevin LaBranche (@klabranche) Avatar

    More precisely: Nope nope nope and more nope with an extra side of nope sauce for dipping and furthermore nnnnnnope. JUST MADE MY DAY! 🙂

  2. benday Avatar

    Hahahahaha! Glad you liked it! 🙂

  3. Irene T. Avatar
    Irene T.

    Ben, this is the second time you helped me tremendously with the TFS build! Thank you so much!!!!

  4. dllundin Avatar

    made my day and saved ton of time. great clean explanation – TY!

  5. carlowahlstedt Avatar

    hey, thanks for this. So it works but…it’s outputing more dlls than the site needs. Interestingly, I have another site that compiles just fine, with all the proper System.*.dlls. The other project is building along side several .net standard libraries. I’m wondering if this has something to do with it.

  6. Dominic Burford Avatar

    Fantastic. I ran into this problem after upgrading our ASP.NET Core 2.0 web application to 2.1. Thanks to your artricle I have now successfully resoved the problem. Thank you 🙂

  7. pkg01 Avatar
  8. SV (@svbgv) Avatar

    god fucken bless you dude ♥

  9. […] some investigation and finding this blog post it appears that this is intentional on Microsoft’s part but that if you want to include […]

  10. joanneraye Avatar

    I am having similar issues and when I put the the suggested false in my project file, my dot net core 3.1 project cannot load in Visual Studio. Any ideas? I have been working on this problem for days (15+ hours) and can’t get anywhere. My deps.json file is saying that it can’t find one of my net standard libraries that I wrote. Thanks.

  11. joanneraye Avatar

    Never mind – I had added it wrong. Once I added to csproj file, it made no difference.

  12. Peter Drier Avatar
    Peter Drier

    Anyone know if something like this is available for non ASP, i.e. .Net Core 3.1 WPF, apps?

  13. […] Force ‘dotnet publish’ to publish dependencies using PublishWithAspNetCoreTargetManifest by Benjamin Day […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.