MATLAB Compiler SDK で作成された DLL ファイルのプロパティ情報を設定することはできますか?
3 ビュー (過去 30 日間)
古いコメントを表示
MathWorks Support Team
2025 年 7 月 9 日
回答済み: MathWorks Support Team
2025 年 7 月 9 日
MATLAB Compiler SDK を使用して DLL ファイルを作成しているのですが、バージョン管理を行えるように、ファイルのアセンブリバージョンやその他のプロパティ情報を設定したいと考えています。方法を教えてください。
採用された回答
MathWorks Support Team
2025 年 7 月 9 日
R2019b およびそれ以降の MATLAB Compiler SDK ではライブラリコンパイラアプリでバージョンを指定できます。
また、「mcc」でversion=version_number" 「-W」引数リストの末尾に「」を追加することでバージョンを指定することもできます。
バージョン番号およびその他のプロパティ情報を設定するには以下のような外部ファイルで指定する方法があります。
1) ライブラリコンパイラ画面の「設定」ボタンにより設定画面を開き「mccに渡される追加パラメーター」の部分に「-C -v」を追加し、この状態で「パッケージ化」ボタンによりビルドします。
2) ライブラリコンパイラのプロジェクトファイルと同じフォルダに「properties.cs」ファイルを作成します。このファイルの中身を以下のようにします(情報は適宜変更してください)。
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("myTitle")]
[assembly: AssemblyDescription("my des")]
[assembly: AssemblyConfiguration("my config")]
[assembly: AssemblyCompany("my comp")]
[assembly: AssemblyProduct("my prod")]
[assembly: AssemblyCopyright("my cr")]
[assembly: AssemblyTrademark("my tm")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.5.0.0")]
[assembly: AssemblyFileVersion("3.0.0.0")]
3) ライブラリコンパイラにより生成された「PackagingLog.html」をブラウザ等で開きます。「csc.exe」実行時に使用されたコマンドラインが 2 つあります。例えば以下のようなものです。
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /nologo /optimize /doc:"C:\path\to\project\mytest\for_testing\mytest.xml" /t:library /r:"C:\Program Files\MATLAB\R2016a\toolbox\dotnetbuilder\bin\win64\v2.0\MWArray.dll" /resource:"C:\path\to\project\mytest\for_testing\mytest.ctf" /out:"C:\path\to\project\mytest\for_testing\mytest.dll" "C:\path\to\project\mytest\for_testing\Class1.cs"
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /nologo /optimize /doc:"C:\path\to\project\mytest\for_testing\mytestNative.xml" /t:library /r:"C:\Program Files\MATLAB\R2016a\toolbox\dotnetbuilder\bin\win64\v2.0\MWArray.dll" /resource:"C:\path\to\project\mytest\for_testing\mytest.ctf" /out:"C:\path\to\project\mytest\for_testing\mytestNative.dll" "C:\path\to\project\mytest\for_testing\Class1Native.cs"
4) 上記のコマンドラインの最後の部分に 2) で作成した「properties.cs」を追加します。こちらはフルパスで指定します。さらに MATLAB のコマンドウィンドウで実行するために先頭に「!」を付け「csc.exe」の部分にダブルコーテーション「" "」を付けます。その結果以下のようになります。
>>!"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /nologo /optimize /doc:"C:\path\to\project\mytest\for_testing\mytest.xml" /t:library /r:"C:\Program Files\MATLAB\R2016a\toolbox\dotnetbuilder\bin\win64\v2.0\MWArray.dll" /resource:"C:\path\to\project\mytest\for_testing\mytest.ctf" /out:"C:\path\to\project\mytest\for_testing\mytest.dll" "C:\path\to\project\mytest\for_testing\Class1.cs" "C:\path\to\project\mytest\for_testing\properties.cs"
>>!"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe" /nologo /optimize /doc:"C:\path\to\project\mytest\for_testing\mytestNative.xml" /t:library /r:"C:\Program Files\MATLAB\R2016a\toolbox\dotnetbuilder\bin\win64\v2.0\MWArray.dll" /resource:"C:\path\to\project\mytest\for_testing\mytest.ctf" /out:"C:\path\to\project\mytest\for_testing\mytestNative.dll" "C:\path\to\project\mytest\for_testing\Class1Native.cs" "C:\path\to\project\mytest\for_testing\properties.cs"
5) 上記の 2 つのコマンドを MATLAB のコマンドプロンプトから実行します。
6) 生成された mytest.dll ファイルを右クリックいただき「プロパティ」選択により表示されたプロパティウィンドウの「詳細」タブにより内容をご確認いただくことができます。
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で MATLAB Compiler SDK についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!