visual-studio.net-corevisual-studio-macself-contained

Self-contained Linux 64 package on Visual Studio for Mac


When working with a .NET Core app in Visual Studio 2019 for Windows I have options to publish app as a Windows, Linux or Mac package, framework-dependent or self-contained. I must be missing something obvious, but how do I do the same in Visual Studio for Mac? It's just publishes stuff without asking for any options.

I tried manually edit publishing profile to include last 2 lines:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <PublishProvider>FileSystem</PublishProvider>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>AnyCPU</LastUsedPlatform>
    <publishUrl>../../dist</publishUrl>
    <ExcludeAppData>False</ExcludeAppData>
    <DeleteExistingFiles>true</DeleteExistingFiles>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <RuntimeIdentifier>linux-64</RuntimeIdentifier>
    <SelfContained>true</SelfContained>
  </PropertyGroup>
</Project>

but they seem to have no effect.


Solution

  • I ended up doing this in .NET CLI

    dotnet publish -o dist/  -r linux-x64 src/
    

    If you specify the runtime identifier - by default it builds self-contained package.