Search code examples
msbuildmstestassemblyinfomsbuildcommunitytasksinternalsvisibleto

Setting Assembly Info for InternalsVisibleTo with MSBuild Community Tasks


I'm using MSBuild Community Tasks to automatically update my assembly version numbers according to my Subversion repository tag. I have added the following to my project file:

This gives me a new AssemblyInfo.cs file: unfortunately I need to add the following to get my MStests to work properly:

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XLComponentsUnitTests")]

But I cannot figure out how to do this - there doesn't seem to be anyway through the MSBuild Community Tasks, for example. Can anyone provide guidance on this?


Solution

  • Simple answer: Since this is not supported by the MSBuild community task, add this to one of the files of your project.

    #ifdef DEBUG
    [assembly: System.Runtime.CompilerServices.InternalsVisibleTo("XLComponentsUnitTests")]
    #endif
    

    There is nothing that says the assembly attributes have to all be in one file, or all generated by the <AssemblyInfo> task.