Fork me on GitHub

InternalsVisibleTo

Gentoo Mono Handbook
MSDN: en, ru
mono.snk - installation and usage
How to make signed assembly?
How many instances of System.Runtime.CompilerServices.InternalsVisibleToAttribute are allowed, only one or several of them? Many (MSDN)
[AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = true, 
	Inherited = false)]
public sealed class InternalsVisibleToAttribute : Attribute

InternalsVisibleTo attribute can be generated by
MSBuild.Community.Tasks
https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/AssemblyInfo.cs#L439-L449
public key can be retrieved with sn pipelined to grep (isn't it easier to encode that logic into separate task? this will not require external tools and their error processing with bash)
need to check the implementation of internals visible to in that task

it is possible to conditionally include files in msbuild project. Conditions can check msbuild properties which are passed to xbuild from command line.
i.e. /p:SignAssembly=true
MSBuild Conditions (MSDN)

Adding into project

[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=002400000480000094000000060200000024000052534131000400000100010079159977d2d03a8e6bea7a2e74e8d1afcc93e8851974952bb480a12c9134474d04062447c37e0e68c080536fcf3c3fbe2ff9c979ce998475e506e8ce82dd5b0f350dc10e93bf2eeecf874b24770c5081dbea7447fddafa277b22de47d6ffea449674a4f9fccf84d15069089380284dbdd35f46cdff12a1bd78e4ef0065d016df")]

mpt-csproj

mpt-csproj --inject-InternalsVisibleTo=Newtonsoft.Json.Tests --AssemblyKeyContainerName=mono Newtonsoft.Json.csproj
mpt-csproj --inject-InternalsVisibleTo=Newtonsoft.Json.Tests --AssemblyOriginatorKeyFile=mono.snk Newtonsoft.Json.csproj

Links

http://stackoverflow.com/questions/8983097/internalsvisibleto-attribute-not-compiling-under-xbuild-mono-2-10-6-but-works
without strongly-naming the assemblies and the error doesn't occur if they're not.
https://github.com/JamesNK/Newtonsoft.Json/issues/353
Src/Newtonsoft.Json/Properties/AssemblyInfo.cs
[assembly: InternalsVisibleTo("Newtonsoft.Json.Tests")]

Properties/AssemblyInfo.cs(92,12): error CS1726: Friend assembly reference `Newtonsoft.Json.Tests' is invalid. Strong named assemblies must specify a public key in their InternalsVisibleTo declarations

Properties/AssemblyInfo.cs(92,12): error CS0117: `System.Runtime.CompilerServices.InternalsVisibleToAttribute' does not contain a definition for `PublicKey'
^^ that's because PublicKey should be inside the string, not as a separate attribute