-
Notifications
You must be signed in to change notification settings - Fork 264
Description
In the packages.config world, when references are actually added to the user's project file, the project system will add <EmbedInteropTypes>true</EmbedInteropTypes>
metadata to the reference when its sniff-test tells it that the assembly should be linked rather than referenced. This is an important distinction for several reasons.
But in the project.json world, this is lost -- the project system has no say in the matter, and the build system seems to reference everything even when it should be linked. This will break scenarios when Visual Studio SDK extensions use NuGet packages for such references as Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime
as the types won't be embedded, and although the extension might work on that developer's machine (who has the VS SDK installed), the extension will fail at runtime on the end user's machine because that assembly isn't present. It was supposed to be embedded into the extension author's assembly!
I discussed this in a design meeting with @davidfowl and @jasonmalinowski in mid-September, 2015. But I haven't heard that anything came of it afterward. The design IIRC was that the NuPkg should support a new link
folder next to lib
and ref
. The assemblies in the link
folder get passed to the compiler with /link:
instead of /ref:
.
So a package with this file layout:
MyPackage.nuspec
lib\
net45\
MyRegularAssembly.dll
link\
net45\
MyContracts.EmbedME.dll
When consumed by a C# project would produce a command line like this:
csc.exe /ref:MyPackage\1.0.0\lib\net45\MyRegularAssembly.dll /link:MyPackage\1.0.0\link\net45\MyContracts.EmbedME.dll
Design Spec - https://github.com/NuGet/Home/wiki/Embed-Interop-Types-with-PackageReference