NuGet / Samples

NuGet team sample repo
Other
136 stars 108 forks source link

Can't correctly embed interop types for packagereference #58

Open nduane opened 1 year ago

nduane commented 1 year ago

While the suggestion here helps:

https://github.com/NuGet/Samples/blob/main/NuGet.Samples.Interop/README.md

and almost works, ie. it will fix it such that VS will build and won't include the interop assembly in the manifest, however, the interface types are not 'dynamic' as they were when you included a 'reference' to an interop assembly. This causes all the method calls/property sets/gets to show 'like' errors, flagged with red squigglies, in the editor even though the build succeeds.

Also, seems the suggestion in:

https://github.com/NuGet/Samples/blob/main/NuGet.Samples.Interop/README.md

is not quite correct. I needed to remove this part:

AND '%(ReferencePath.NuGetPackageId)' == '$(MSBuildThisFileName)'

krisnuttall commented 5 months ago

Looking at all the properties in the PropertyReference, it looks like NuGetPackageId is no longer set (at least from .net4.8):

This page shows how to view all properties: https://stackoverflow.com/questions/17461175/how-to-get-all-the-metadata-keys-for-any-itemgroup-item

zivkan commented 5 months ago

As easier way to see item metadata is to take an msbuild binlog (msbuild -bl) and view using https://msbuildlog.com