VS CodeでVB.NETの自己完結型単一ファイルのEXEをコンパイルする方法を紹介します。
1. プロジェクトの作成
まず、VB.NETのプロジェクトを作成します。
dotnet new winforms -lang vb -o MyApp
cd MyApp
2. vbproj
ファイルの設定
プロジェクトファイル (MyApp.vbproj
) を開き、以下の設定を追加します。
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<PublishSingleFile>true</PublishSingleFile>
<SelfContained>true</SelfContained>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
3. EXEファイルのコンパイル
以下のコマンドを実行して、自己完結型の単一ファイルEXEを作成します。
dotnet publish -c Release -r win-x64 --self-contained true -p:PublishSingleFile=true
4. 出力ファイルの確認
発行されたEXEファイルは、以下のディレクトリに生成されます。
MyApp\bin\Release\net8.0\win-x64\publish\MyApp.exe
このEXEファイルは**.NETランタイムなしで動作**します。
参考情報
詳しい手順は、Qiitaの記事やMicrosoftの公式ドキュメントを参考にしてください。