addmoduletoassemblyusingcsharpcompiler

Cancel Edit [WikiEntry.PreviewButtonText] Save

How do I link additional modules into an assembly?


Pre Beta 1

The Csc task supported a parameter called "AdditionalModules" which could be used to pass in a list of additional modules that should be "linked" into the assembly being built. This parameter maps to the /addmodule switch on the csc.exe command-line.

Beta 1 and beyond

In the "Beta 1" timeframe, the parameter on the Csc task was renamed to "AddModules", but its behavior remains the same.

In terms of the .TARGETS files that are distributed with ""MSBuild"", in particular ""Microsoft.CSharp.targets"", the call to the Csc task did not pass in any value for the ""AdditionalModules"" parameter in the ""Pre-Beta1"" timeframe. Therefore, ""Pre-Beta1"", if you wanted to have a Visual Studio project file that took advantage of this parameter, you'd either have to manually modify ""Microsoft.CSharp.targets"", or override the "Compile" target in your own .CSPROJ project file. In ""Beta 1"" and beyond, this was fixed so that now the ""Microsoft.CSharp.targets"" file looks something like this:

		    <Target
		        Name="Compile"
		        ...>
	

		        <Csc 
		              ...
		              AddModules="@(AddModules)"
		              ...
		              />
		    </Target>
	

This allows you to simply create an item called "AddModules" in your .CSPROJ file without having to touch the .TARGETS file.
Microsoft Communities