Home > OS >  Producing Executable for a C# project in linux
Producing Executable for a C# project in linux

Time:10-26

I want to know how to produce a c# executable file on Linux as when I build all I get is a DLL file in the bin folder that I don't know how to execute. Note: I'm using vscode as my code editor and Manjaro is my Linux distro.

CodePudding user response:

Did you try command?

dotnet app_name.dll

CodePudding user response:

I guess a Publish Profile is What You are looking for.

Add a file named MyPublishProfile.pubxml to your project with this content:

    <?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
  <PropertyGroup>
    <DeleteExistingFiles>false</DeleteExistingFiles>
    <ExcludeApp_Data>false</ExcludeApp_Data>
    <LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <PublishProvider>FileSystem</PublishProvider>
    <PublishUrl>bin\Release\net6.0\publish\</PublishUrl>
    <WebPublishMethod>FileSystem</WebPublishMethod>
    <_TargetId>Folder</_TargetId>
    <SiteUrlToLaunchAfterPublish />
    <TargetFramework>net6.0</TargetFramework>
    <RuntimeIdentifier>linux-x64</RuntimeIdentifier>
    <ProjectGuid>c21872b8-42b3-418a-ab47-103a60e7cd6c</ProjectGuid>
    <SelfContained>true</SelfContained>
  </PropertyGroup>
</Project>

save it and edit it (follow the provided links). then you can run

dotnet publish -p:publishProfile=MyPublishProfile

then you should have your excecutable. maybe you have to chmode it. you can read more here

  • Related