PublishSingleFile=true does not include Content files
See original GitHub issueI am working with a (non-web) .NET Core 3.0 console application and I am trying to use PublishSingleFile=true
. While the single-file aspect does indeed work (I get one executable file), my application always crashes due to missing appsettings.json files. I’ve tried setting the files to Content/None, Copy Always/Newest. I also tried adding <CopyToPublishDirectory>true</CopyToPublishDirectory>
and yet nothing seems to work.
If I create a brand new fresh Web-SDK project, the single file publish works and the content files are dropped right next to the published executable. I tried comparing the starter web project to my console application and I don’t see a difference.
The easiest reproduction I have is to create a blank console application project, add a text file to the project (as content or none
) and then publish with the PublishSingleFile=true. The output does not contain the content files.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
</PropertyGroup>
<ItemGroup>
<Content Include="MyContentFile.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</Content>
</ItemGroup>
</Project>
Is this supposed to work for non-Web projects?
.NET Core SDK (reflecting any global.json): Version: 3.0.100 Commit: 04339c3a26
Runtime Environment: OS Name: Windows OS Version: 10.0.18362 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\3.0.100\
Host (useful for support): Version: 3.0.0 Commit: 95a0a61858
.NET Core SDKs installed: 3.0.100-rc1-014190 [C:\Program Files\dotnet\sdk] 3.0.100 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Hi @pinkfloydx33 for in the case of
PublishSingleFile
all published content is bundled into the single-file. If we need files to be left behind in the publish directory, we need to set theExcludeFromSingleFile
property. In your example:For more details, please see: https://github.com/dotnet/designs/blob/master/accepted/single-file/design.md#build-system-interface
Dup of https://github.com/dotnet/core-setup/issues/7738
Dears, Is there is a way to excluded Package Reference DLLs from being bundled in single file application? I am working on WPF application .NET 5.0