1

I'm successfully publishing a .NET Core App via Visual Studio but am unable to do the same via command-line (or using the Developer Command Prompt for VS 2019).

I'm using the Publish profile generated by VS2019 and doing:

dotnet publish -p:PublishProfile=Properties\PublishProfiles\MyProfile.pubxml

where MyProfile is:

<?xml version="1.0" encoding="utf-8"?>

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
   <PublishProtocol>FileSystem</PublishProtocol>
   <Configuration>Release</Configuration>
   <Platform>Any CPU</Platform>
   <TargetFramework>netcoreapp3.1</TargetFramework>
   <PublishDir>..\Build\Release\publish\</PublishDir>
   <RuntimeIdentifier>win-x64</RuntimeIdentifier>
   <SelfContained>true</SelfContained>
   <PublishSingleFile>False</PublishSingleFile>
   <PublishReadyToRun>False</PublishReadyToRun>
   <PublishTrimmed>False</PublishTrimmed>
 </PropertyGroup>
</Project>

And the error that I always get is:

MyCustom.dll. Could not load type 'Microsoft.Build.Utilities.AppDomainIsolatedTask' from assembly 'Microsoft.Build.Utilities.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.

What am I missing?

João Pereira
  • 673
  • 1
  • 9
  • 29

1 Answers1

0

I found a workaround, rather than a fix.

If we use msbuildto publish, I'm able to have the same result as dotnet publish and it runs successfully in the command-line:

msbuild /restore /t:Publish /p:RuntimeIdentifier=win-x64 /p:configuration=Release
João Pereira
  • 673
  • 1
  • 9
  • 29