This tool unfortunately provides token .Net infrastructure support. It can produce a strongly named assembly but it does not have facility to allow user to specify the assembly version data, a vital piece of information to support strict version binding policy.
Every assembly produced by NE Builder, regardless strongly name or not, has the version 0.0.0.0. As a result it is not very useful. According to Matlab forum, Matlab does not have any way to deal with this issue. This blog post provides a recipe of allowing user to add assembly version or any other pieces of information to the NE Builder produced assembly. It does not use any undocumented or hack to produce the result; it simply uses the same standard .Net build specifications the NE Builder Deployment tool uses.
- From the Deployment tool (read NE Builder) build the assembly and making sure that you clear the "Embedded the CTF Archive". This is because when you use embedded CTF archive, the builder deletes the CTF file after building the assembly. We need this file in the subsequent steps and hence not embedding lets us access this file. Furthermore, it is easier if you make the source and output directory the same.
- Save the build steps to a build log and open it with a text editor.
- Look out for the line containing the CSC.exe as we will use that to produce the response file for the C# compiler.
- Copy the text after CSC.exe into a text file. You can insert line break to make it more readable.
- Add AssemblyInfo.cs to the response file. This file contains the assembly information you wish to include into the assembly.
- Save the text file into a file with customary .rsp extension into the same directory as the source.
- Create the AssemblyInfo.cs file if not exist and specify your assembly version and other information.
- Run the CSC with this response file to produce your assembly which will contain the required assembly version.
This recipe then allows one to produce a versionable strong name .Net assembly that carries the Matlab script.
4 comments:
The output DLL comes without CTF file embedded in it, and it doesn't work
You are correct in that the output DLL does not have the CTF as we deliberately not embedding it. The message you are referring to does has one key instruction missing. That is the use of /linkres in the CSC compiler to define a resource (external) linkage to the CTF file. Without this you will have to manually carry this CTF to the location of the DLL.
Please refer to my other message http://do-the-right-things.blogspot.com.au/2011/05/complete-build-process-of-matlab.html for discussion of this. If you have provided an e-mail address, I can discuss this matter with you.
We have used this technique in many Matlab NE generated project.
What do you mean with "5. Add AssemblyInfo.cs to the response file"?
This step is not Matlab specific but a standard build process of any .Net assembly.
The AssemblyInfo.cs contains among other assembly identification information the most relevant piece in this discussion, the AssemblyVersion.
Including this file into the response file ensure that the build process will include the version number with your final Matlab assembly. In the standard Matlab build, this is not defined and hence resulting in version 0.0.0.0.
Post a Comment