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

dotnet build with GeneratePackageOnBuild and contentFiles

$
0
0

hopefully this is not a duplicate but I didn't find or catch the solution to my problem in the other posts.

I have a project that I'm building with dotnet build -c Release /p:Platform=x86 .\Foo.csproj.The csproj file is in SDK format and have this content:

<?xml version="1.0" encoding="utf-8"?><Project Sdk="Microsoft.NET.Sdk.WindowsDesktop"><PropertyGroup><TargetFramework>net48</TargetFramework><GeneratePackageOnBuild>true</GeneratePackageOnBuild><AssemblyName>Foo</AssemblyName><Company>Me</Company><Authors>Me</Authors><Version>4.12.5</Version><AssemblyVersion>4.12.5.0</AssemblyVersion><FileVersion>4.12.5.0</FileVersion><Platforms>x86</Platforms><UseWPF>true</UseWPF></PropertyGroup><ItemGroup><ProjectReference Include="..\Bar.csproj">[...]</ProjectReference></ItemGroup><ItemGroup Label="FilesToCopy"><Content Include="..\dependent.dll" Pack="true" PackagePath=".\lib\net48\" PackageCopyToOutput="true" /><None Include="image.jpg" Pack="true" PackagePath=".\contentFiles\any\any\" PackageCopyToOutput="true" /></ItemGroup><ItemGroup><None Update="tex_cardboard.jpg"><CopyToOutputDirectory>Always</CopyToOutputDirectory></None></ItemGroup><PropertyGroup><TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);CopyProjectReferencesToPackage</TargetsForTfmSpecificBuildOutput></PropertyGroup><Target Name="CopyProjectReferencesToPackage" DependsOnTargets="ResolveReferences"><ItemGroup><BuildOutputInPackage Include="@(ReferenceCopyLocalPaths-&gt;WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))" /></ItemGroup></Target></Project>

This will generate a nuget package on build with the image.jpg in a contentFiles\any\any folder.

If I understand correctly, the the .nuspec file inside of the nuget package should contain:

<contentFiles><files include="**/*" buildAction="Content" /></contentFiles>

But it does not.

How do I tell, in the csproj file, the image file to be included as content and not to be compiled?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



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