I have the following declared in my csproj
.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="TextFile1.txt" Link="Files\TextFile1.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Files\TextFile2.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
Upon building the application I am getting the following bin/debug structure
As you can see both files are in the subdirectory Files
, and no text file is in the root folder, since the file in the root folder isn't marked as <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
but the link is.
Now I want to pack this application, which fails to respect my linking of the file and dumps the TextFile1.txt
into the root folder.
The created *.nuspec
file looks like this
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata>
<id>ConsoleApp44</id>
<version>1.0.0</version>
<authors>ConsoleApp44</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Package Description</description>
<dependencies>
<group targetFramework="net5.0" />
</dependencies>
<contentFiles>
<files include="any/net5.0/TextFile1.txt" buildAction="Content" />
<files include="any/net5.0/Files/TextFile2.txt" buildAction="Content" />
</contentFiles>
</metadata>
</package>