Skip to content

Instantly share code, notes, and snippets.

@h1romas4
Last active July 12, 2026 06:08
Show Gist options
  • Select an option

  • Save h1romas4/0056b99e67ee802a0efb0c97c77448c9 to your computer and use it in GitHub Desktop.

Select an option

Save h1romas4/0056b99e67ee802a0efb0c97c77448c9 to your computer and use it in GitHub Desktop.
mml2vgm Core for .NET Core 10 patch
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<OutputType>Library</OutputType>
<RootNamespace>Core</RootNamespace>
<AssemblyName>Core</AssemblyName>
<Platforms>AnyCPU</Platforms>
<!-- repository supplies AssemblyInfo.cs -->
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<!-- Prevent SDK from auto-generating TargetFrameworkAttribute (avoids duplicate attribute errors) -->
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<!-- Suppress noisy/known warnings from legacy code and packaging -->
<!-- Update this list to remove specific entries when code is cleaned up -->
<NoWarn>$(NoWarn);CS8981;CS0108;SYSLIB0012;CS0414;CS0168;CS0219</NoWarn>
</PropertyGroup>
<ItemGroup>
<!-- keep local/unmanaged dll references -->
<Reference Include="MDSound">
<HintPath>$(MSBuildThisFileDirectory)dll\\MDSound.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="musicDriverInterface">
<HintPath>$(MSBuildThisFileDirectory)dll\\musicDriverInterface.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<!-- package references needed for compatibility -->
<PackageReference Include="System.Drawing.Common" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<Content Include="dll\\MDSound.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<!-- SDK-style will compile all .cs files by default; prevent duplicate AssemblyInfo.cs generation -->
<Compile Remove="Properties\AssemblyInfo.cs" /> <!-- exclude local build stub when real DLL is referenced -->
</ItemGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>portable</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin/Debug/</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>true</Optimize>
<DebugType>none</DebugType>
<OutputPath>bin/Release/</OutputPath>
</PropertyGroup>
</Project>
diff --git a/home/hiromasa/devel/dotnet/mml2vgm/mml2vgm/Core/message.cs b/home/hiromasa/devel/dotnet/mml2vgm-dotnet/mml2vgm-core/message.cs
index 94b27b8..11cb989 100644
--- a/home/hiromasa/devel/dotnet/mml2vgm/mml2vgm/Core/message.cs
+++ b/home/hiromasa/devel/dotnet/mml2vgm-dotnet/mml2vgm-core/message.cs
@@ -12,7 +12,16 @@ namespace Core
static msg()
{
Assembly myAssembly = Assembly.GetEntryAssembly();
- string path = Path.GetDirectoryName(myAssembly.Location);
+ string path = null;
+ if (myAssembly != null && !string.IsNullOrEmpty(myAssembly.Location))
+ {
+ path = Path.GetDirectoryName(myAssembly.Location);
+ }
+ // Assembly.Location is empty for single-file apps — fall back to AppContext.BaseDirectory
+ if (string.IsNullOrEmpty(path))
+ {
+ path = System.AppContext.BaseDirectory.TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar);
+ }
string lang = System.Globalization.CultureInfo.CurrentCulture.Name;
string file = Path.Combine(path, "lang", string.Format("message.{0}.txt", lang));
file = file.Replace('\\', Path.DirectorySeparatorChar).Replace('/', Path.DirectorySeparatorChar);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment