Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How to copy a folder into nuget package using BuildOutputInPackage

$
0
0

I am trying to copy a folder into a nuget package, on a multi-targeted project.

My input folder is Example, and I want it's content copied into a folder Example in the nuget package (for each lib version)

I am following the docs for BuildOutputInPackage: https://learn.microsoft.com/en-us/nuget/reference/msbuild-targets#advanced-extension-points-to-create-customized-package

I have a .csproj with the following:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFrameworks>netstandard2.0;net48</TargetFrameworks></PropertyGroup><PropertyGroup><TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);Example</TargetsForTfmSpecificBuildOutput></PropertyGroup><Target Name="Example"><ItemGroup><BuildOutputInPackage Include="$(ProjectDir)Example\**\*.*"><TargetPath>Example</TargetPath></BuildOutputInPackage></ItemGroup></Target></Project>

Given I have

  • Example/1.txt
  • Example/2.txt

Only the first file gets copied when TargetPath is present, and msbuild emits a warning: {File} not added because the package already contains file {TargetPath}

However if I remove TargetPath, all files are copied, but to the root directory.

How can I copy all files to a custom directory?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>