Is it possible to set the Assembly Version and other Property info of a .DLL created with MATLAB Compiler SDK or MATLAB Builder?
5 views (last 30 days)
Show older comments
MathWorks Support Team
on 19 Mar 2024
Edited: MathWorks Support Team
on 9 Dec 2024
I am creating a .DLL and would like to set the Assembly Version and other Property info of the file to able to handle versioning of our assemblies. How can I do this?
Accepted Answer
MathWorks Support Team
on 9 Dec 2024
Edited: MathWorks Support Team
on 9 Dec 2024
R2018a or earlier
The possibility to version .NET assemblies is not possible in MATLAB. To workaround this limitation, create an "Assemblyinfo.cs" file which you attach as "Shared Resources and Helper Files" in your "deploytool" project.
Adjusting the entries as needed, the contents of the "Assemblyinfo.cs" file should be:
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.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
R2019b and newer
As of R2019b, on Windows, the version can be specified in the Library Compiler tool. Additionally, the version can be specified in "mcc" by appending "version=version_number" to end of the "-W" arguments list.
If the version number needs to be specified in an external file, one can still give the .DLL a version number by following these steps:
1) Compile the .DLL with "-C" (uppercase) flag and the "-v" flag.
2) Now, create a properties.cs file. That file has the following content below:
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")]
In this step, you can adjust the assembly attributes above to your own needs.And4) Take these calls and add the properties.cs file path to the end. Then run them again from the MATLAB command window. For example:Do the same for the second call to csc.exe.
3) If using the Library Compiler, look in the PackagingLog.html (or .txt) file again for calls to csc.exe. If using command line compilation, look for the displayed output calls to csc.exe. There should be two calls to it. The two calls may be in one single line. The two separate calls may look something like:
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"
>>!"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"
The .DLL should now have the correct version number.
0 Comments
More Answers (0)
See Also
Categories
Find more on MATLAB Compiler SDK in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!