Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Compile .NET Assemblies from Command Line

Command-Line Syntax Description

Instead of using the Library Compiler app to create .NET assemblies, you can use the mcc command.

The following command defines the complete mcc command syntax with all required and optional arguments used to create a .NET assembly. Brackets indicate optional parts of the syntax.

mcc -W 'dotnet:component_name,class_name, 0.0|framework_version, Private|Encryption_Key_Path,local|remote' file1 [file2...fileN][class{class_name:file1 [,file2,...,fileN]},... [-d output_dir_path] -T link:lib

.NET Bundle

You can simplify the command line used to create .NET assemblies. To do so, use the bundle named dotnet. Using this bundle still requires that you pass in the five parts (including local|remote) of the -W argument text string; however, you do not have to specify the -T option.

The following example creates a .NET assembly called mycomponent containing a single .NET class named myclass with methods foo and bar.

mcc -B 'dotnet:mycomponent,myclass,2.0,
    encryption_keyfile_path,local'
    foo.m bar.m

In this example, the compiler uses the .NET Framework version 2.0 to compile the component into a shared assembly using the key file specified in encryption_keyfile_path to sign the shared component.

Creating a .NET Namespace

The following example creates a .NET assembly from two MATLAB® files foo.m and bar.m.

mcc -B 
'dotnet:mycompany.mygroup.mycomponent,myclass,0.0,Private,local'
 foo.m bar.m

The example creates a .NET assembly named mycomponent that has the following namespace: mycompany.mygroup. The component contains a single .NET class, myclass, which contains methods foo and bar.

To use myclass, place the following statement in your code:

using mycompany.mygroup;

Adding Multiple Classes to an Assembly

The following example creates a .NET assembly that includes more than one class. This example uses the optional class{...} argument to the mcc command.

mcc -B 'dotnet:mycompany.mycomponent,myclass,2.0,Private,local' foo.m bar.m 
class{myclass2:foo2.m,bar2.m}

The example creates a .NET assembly named mycomponent with two classes:

  • myclass has methods foo and bar

  • myclass2 has methods foo2 and bar2

See for a list of supported framework versions.

Execute Compiler Projects with deploytool

The deploytool command has two flags to invoke one of the compiler apps without opening a window.

  • -build project_name — Invoke the correct compiler app to build the project and not generate an installer.

  • -package project_name — Invoke the correct compiler app to build the project and generate an installer.

For example, deploytool -package magicsquare generates the binary files defined by the magicsquare project and packages them into an installer that you can distribute to others.

Was this topic helpful?