2017-01-26 23 views
0

我试图通过使用下面的语法罗斯林元数据引用添加到我的VB.NET工程:如何通过roslyn添加参考“copy local”true?

project = project.AddMetadataReference(
    MetadataReference.CreateFromFile(
     package.FullName, 
     MetadataReferenceProperties.Assembly)); 

不过,我需要设置“本地复制”到true这种组装,那怎么办?看起来像汇编参考我只有WithEmbedInteropTypesWithAliases可用,如何设置特定参考的其余属性......?

回答

2

我怀疑“复制本地”是一个MSBuild功能,而不是编译器功能。如果你看一下csc命令行:

     - INPUT FILES - 
/recurse:<wildcard>   Include all files in the current directory and 
           subdirectories according to the wildcard 
           specifications 
/reference:<alias>=<file>  Reference metadata from the specified assembly 
           file using the given alias (Short form: /r) 
/reference:<file list>  Reference metadata from the specified assembly 
           files (Short form: /r) 
/addmodule:<file list>  Link the specified modules into this assembly 
/link:<file list>    Embed metadata from the specified interop 
           assembly files (Short form: /l) 
/analyzer:<file list>   Run the analyzers from this assembly 
           (Short form: /a) 
/additionalfile:<file list> Additional files that don't directly affect code 
           generation but may be used by analyzers for produ 
cing 
           errors or warnings. 

你可以做/reference:<alias>=<file>得到一个别名,或/link:<file list>嵌入互操作的元数据,但没有选择这里“复制本地”。

您必须自己执行复制。