Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent embedding interop types in nuspec package file

I've created a nuget package for an interop library. When using this package, Nuget automatically sets "Embed Interop Types" to "True".

However, in my project this should be "False".

Is there a way in Nuget to specify that interop types should not be embedded?

like image 235
Merijn Avatar asked Nov 21 '16 09:11

Merijn


People also ask

What does Nuspec file do?

A . nuspec file is an XML manifest that contains package metadata. This manifest is used both to build the package and to provide information to consumers. The manifest is always included in a package.

How do I read a Nuspec file?

There is the Manifest class which is used to read the . nuspec file. The ZipPackage does not directly give you access to the Manifest. Information from the Manifest is available as properties on the ZipPackage class.


1 Answers

I know it's quite an old question but if someone faces this then follow the below steps :

While creating a NuGet package, add a tools folder and add a file named: install.ps1

Write below PowerShell commands which define the project requirement, In my case, I had to add EmbedInteropTypes: false for SapROTWr library.

param($installPath, $toolsPath, $package, $project)

$project.Object.References | Where-Object { $_.Name -eq "Interop.SapROTWr" } |  ForEach-Object { $_.EmbedInteropTypes = $false }

Now add that package to your project and checkout the properties.

like image 159
sobby01 Avatar answered Nov 11 '22 15:11

sobby01