Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't correctly embed interop types for packagereference #58

Open
nduane opened this issue Jan 28, 2023 · 2 comments
Open

Can't correctly embed interop types for packagereference #58

nduane opened this issue Jan 28, 2023 · 2 comments

Comments

@nduane
Copy link

nduane commented Jan 28, 2023

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
Copy link

krisnuttall commented May 28, 2024

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

  • Identity=C:\Users\(user)\.nuget\packages\(package)\(version)\lib\...\(name.dll)
  • HintPath=C:\Users\(user)\.nuget\packages\(package)\(version)\build\...\(name.dll)
  • ReferenceSourceTarget=ResolveAssemblyReference
  • Version=(version)
  • ResolvedFrom={HintPathFromItem)
  • EmbedInteropTypes=true
  • ImageRuntime=v4.0.30319
  • CopyLocal=true
  • OriginalItemSpec=(name.dll)
  • FusionName=...., Version=(version), Culture=neutral, PublicKeyToken=null
  • FullPath=C:\Users\(user)\.nuget\packages\(package)\(version)\lib\...\(name.dll)
  • RootDir=C:\
  • Filename=(name)
  • Extension=.dll
  • RelativeDir=C:\Users\(user)\.nuget\packages\(package)\(version)\lib\...
  • Directory=Users\(user)\.nuget\packages\(package)\(version)\lib\...
  • RecursiveDir=
  • ModifiedTime=2024-05-28 00:00:00.0000000
  • CreatedTime=2024-05-28 00:00:00.0000000
  • AccessedTime=2024-05-28 00:00:00.0000000
  • DefiningProjectFullPath=C:\Program Files\Microsoft Visual Studio\...
  • DefiningProjectDirectory=C:\Program Files\Microsoft Visual Studio\...
  • DefiningProjectName=Microsoft.Common.CurrentVersion
  • DefiningProjectExtension=.targets

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
Copy link
Member

zivkan commented May 28, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants