Home: Pack should emit warning when a targets file is included in build/buildCrossTargeting folder with a name different than package id.

Created on 13 Mar 2018  路  9Comments  路  Source: NuGet/Home

Details about Problem

VS 15.7.0 Preview 1.0
NuGet.exe version: 4.5.1.4879

Detailed repro steps so we can see the same problem

  1. Create a package using nuget.exe pack <packageName>.nuspec containing an arbitrary .targets file.
  2. Try to install the package into a .NET Core 2.0 project
  3. Inspect the contents of project.assets.json file

Result

The target file from the package is not referenced.

While this behavior is by design it'd be better to emit a warning per included target file if it doesn't match certain criteria. The warning can be generated by pack as well as install command.

ErrorHandling Pack 2

Most helpful comment

no. that is by design.
It's a good idea to add the warning to the pack validation.

All 9 comments

@alpaix you know the code, send a PR ;) (JK)

Target file was not referenced until I renamed it after the package name. I presume there's no workaround for that limitation?

no. that is by design.
It's a good idea to add the warning to the pack validation.

is there a specific scenario where you wouldn't want the target file to be named after the package id?

We were trying to package interop assemblies with a boilerplate targets file setting EmbedInteropTypes property to true. So we spent some time trying to understand why it didn't work.

@nkolev92 can you provide Alex with the recommended way of including interop assemblies? I know we have a GitHub sample somewhere

Cool! Thanks! I think I've got one of this sample project variations.

Was this page helpful?
0 / 5 - 0 ratings