I have a .NET 7.0 web-app that I want to publish as a singlefile including all the content of its 'wwwroot' folder and the 'web.config'.
I am trying to publish with
dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true -p:IncludeAllContentForSelfExtract=true
and the following annotation in the .csproj:
<ItemGroup>
<Content Update="wwwroot/**">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>false</ExcludeFromSingleFile>
</Content>
</ItemGroup>
I use 'Update' instead of 'Include' because the files are already included (because of default=true of EnableDefaultContentItems)
After all this I still get a directory 'wwwroot' and the file 'web.config' in the publish directory. Peeking in the .exe i can see there are none of the files included.
Can someone help me publish this webapp as a singlefile?
I have made a console-test-project with files in a subfolder. In this test the configuration above includes the dummy files.