Skip to content

Instantly share code, notes, and snippets.

@johnnyasantoss
Last active September 23, 2024 22:45
Show Gist options
  • Save johnnyasantoss/6cdb25d164db3e101e5973b217c8dc49 to your computer and use it in GitHub Desktop.
Save johnnyasantoss/6cdb25d164db3e101e5973b217c8dc49 to your computer and use it in GitHub Desktop.
Adding .NET related mime types to Linux

Copy this xml to ...

sudo $EDITOR /usr/share/mime/packages/dotnet.xml

Contents:

<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
  <mime-type type="application/x-dotnet-solution">
	  <comment>.NET Solution</comment>
	  <sub-class-of type="text/plain"/>
	  <generic-icon name="text-x-script"/>
	  <glob pattern="*.sln"/>
	</mime-type>
	<!-- Project files -->
	<mime-type type="application/x-dotnet-csharp-project">
    <comment>C# Project</comment>
    <sub-class-of type="text/plain"/>
    <generic-icon name="text-x-script"/>
    <glob pattern="*.csproj"/>
  </mime-type>
	<mime-type type="application/x-dotnet-fsharp-project">
    <comment>F# Project</comment>
    <sub-class-of type="text/plain"/>
    <generic-icon name="text-x-script"/>
    <glob pattern="*.fsproj"/>
  </mime-type>
	<mime-type type="application/x-dotnet-vb-project">
    <comment>VB Project</comment>
    <sub-class-of type="text/plain"/>
    <generic-icon name="text-x-script"/>
    <glob pattern="*.vbproj"/>
  </mime-type>
	<!-- Source code files -->
  <mime-type type="text/x-csharp">
    <comment>C# source code</comment>
    <sub-class-of type="text/x-csrc"/>
    <generic-icon name="text-x-script"/>
    <glob pattern="*.cs"/>
  </mime-type>
  <mime-type type="text/x-fsharp">
    <comment>F# source code</comment>
    <sub-class-of type="text/plain"/>
    <generic-icon name="text-x-script"/>
    <glob pattern="*.fs"/>
  </mime-type>
  <mime-type type="text/x-visualbasic">
    <comment>VB source code</comment>
    <sub-class-of type="text/plain"/>
    <generic-icon name="text-x-script"/>
    <glob pattern="*.vb"/>
  </mime-type>
</mime-info>

$EDITOR should be your favorite file editor. eg. vim, nano, gedit...

After adding the file update the local database

sudo update-mime-database -V /usr/share/mime

More info here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment