You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need ability to pack files from build output folder in multi-targeting projects #4704
It is difficult for users to figure out how to include additional items from the build output folder in a nuget package. The right solution requires adding a target that executes at just the right time, after _CopyFilesMarkedCopyLocal and before _GetPackageFiles. This is made more difficult because _GetPackageFiles only executes on outer builds, not inner builds. It also requires understandings of internal workings of the pack targets.
Scenario: packing a target that includes both the build output.
Ideally, it would be nice if I could express something like this my csproj:
Workaround
Manually add items to the _PackageFiles group in the outer build before the GenerateNuspec task. Make sure to set BuildAction metadata because PackTask throws if it is not set.
@natemcmaster correct, except that you also need to set FinalOutputPath metadata which will be the absolute path of this file on disk.
The result would be that this will put it in lib\TargetFramework folder.
If there is something you want to put outside of the lib folder, use the TargetsForTfmSpecificContentInPackage to write the appropriate target and set the PackagePath.
You can't use TargetsForTfmSpecificBuildOutput to add pdb files for your package (the non-symbols package) because we explicitly filter by extension types on this item group.
You are doing the write thing in your targets above, but it won't work for pdb files for the reason i mentioned above.
To add pdb files to your package, use the TargetsForTfmSpecificContentInPackage property and write a target that looks something like this:
no, that is already taken care of by pack targets. the targets defined in the properties TargetsForTfmSpecificContentInPackage and TargetsForTfmSpecificBuildOutput are run before pack in the tfm-specific build.
@rohit21agrawal Thanks, using TargetsForTfmSpecificContentInPackage instead seems to be working fine. I think I like using that one better anyway since it doesn't require the absolute path of the file.
Out of curiosity, what's the reason for the filter on TargetsForTfmSpecificBuildOutput? What values does it let through?
Activity
natemcmaster commentedon Mar 23, 2017
So, if I understand NuGet/NuGet.Client#1255, the recommend approach now is this:
Right @rohit21agrawal ?
rohit21agrawal commentedon Mar 23, 2017
@natemcmaster correct, except that you also need to set
FinalOutputPathmetadata which will be the absolute path of this file on disk.The result would be that this will put it in lib\TargetFramework folder.
If there is something you want to put outside of the lib folder, use the TargetsForTfmSpecificContentInPackage to write the appropriate target and set the PackagePath.
Feel free to message me for any issues.
natemcmaster commentedon Mar 23, 2017
Thanks!
SimonCropp commentedon Jul 12, 2017
@rohit21agrawal can u share an example of how to
set FinalOutputPath metadatausing the example given by @natemcmaster above?rohit21agrawal commentedon Jul 17, 2017
@SimonCropp Here you go. Let me know if this is still not clear. Sorry for the delay in reply.
bording commentedon Jul 17, 2017
@rohit21agrawal Can you show a working example that has a real value for FinalOutputPath? I'm trying to adapt https://github.com/Particular/NServiceBus/blob/develop/src/Directory.Build.targets#L17 to use
TargetsForTfmSpecificBuildOutputinstead, but I'm not seeing the PDBs show up in the package.Here's what I'm trying that isn't working:
rohit21agrawal commentedon Jul 17, 2017
@bording couple things to note:
TargetsForTfmSpecificContentInPackageproperty and write a target that looks something like this:Let me know if you have anymore questions.
natemcmaster commentedon Jul 17, 2017
@rohit21agrawal don't we also need to chain custom targets to something? What's your recommendation?
GenerateNuspecDependsOnorBefore/AfterTargetsrohit21agrawal commentedon Jul 17, 2017
no, that is already taken care of by pack targets. the targets defined in the properties
TargetsForTfmSpecificContentInPackageandTargetsForTfmSpecificBuildOutputare run before pack in the tfm-specific build.bording commentedon Jul 17, 2017
@rohit21agrawal Thanks, using
TargetsForTfmSpecificContentInPackageinstead seems to be working fine. I think I like using that one better anyway since it doesn't require the absolute path of the file.Out of curiosity, what's the reason for the filter on
TargetsForTfmSpecificBuildOutput? What values does it let through?rohit21agrawal commentedon Jul 18, 2017
@bording here is the list of output extensions it allows : https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Commands/MSBuildProjectFactory.cs#L27
there are two lists , one for the normal package and one for the symbols package.
we are open to listening to user feedback if this comes in the way of your scenario - please feel free to open up an issue .