dotnet publish doesn't include CopyToOutputDirectory/CopyToPublishDirectory files
See original GitHub issueMoved from dotnet/cli#5649 on behalf of @timmydo.
Steps to reproduce
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<WarningsAsErrors>true</WarningsAsErrors>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Platform</AssemblyName>
<OutputType>Exe</OutputType>
<PackageId>Platform</PackageId>
<RuntimeIdentifiers>win7-x64</RuntimeIdentifiers>
<PackageTargetFallback>$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
</PropertyGroup>
<Import Project="..\Global.props" />
<ItemGroup>
<Content Update="wwwroot\**\*;web.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="wwwroot\**\*;web.config;start.bat;Platform.ini;serviceConfig.ini">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Shared\Shared.csproj" />
<ProjectReference Include="..\Models\Models.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.HttpOverrides" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.WebListener" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OAuth" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.CommandLine" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Net.Http" Version="2.2.29" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="1.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="1.1.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="1.0.2" />
<PackageReference Include="Swashbuckle" Version="6.0.0-beta902" />
<PackageReference Include="StyleCop.Analyzers" Version="1.0.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="npm --silent install" />
<Exec Command="gulp --silent --no-color" />
</Target>
</Project>
C:\Users\timmydo\AppData\Local\Temp\dotnet\dotnet.exe publish Platform -r win7-x64 -c release -f netcoreapp1.1 -o ..\test\platform
Expected behavior
expected platform.ini, wwwroot, etc. to exist in publish directory
Actual behavior
files not found
Environment data
dotnet --info
output:
C:\Users\timmydo\AppData\Local\Temp\dotnet\dotnet.exe --info
.NET Command Line Tools (1.0.0-rc4-004777)
Product Information:
Version: 1.0.0-rc4-004777
Commit SHA-1 hash: 18c01886cd
Runtime Environment:
OS Name: Windows
OS Version: 6.3.9600
OS Platform: Windows
RID: win81-x64
Base Path: C:\Users\timmydo\AppData\Local\Temp\dotnet\sdk\1.0.0-rc4-004777
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
ASP.NET Core: Exclude or include files on publish
There is a CopyToPublishDirectory attribute for ItemGroup elements that determines whether to copy the file to the publish directory and can ...
Read more >Keeping Content Out of the Publish Folder for WebDeploy
CopyToOutputDirectory. Copies files to the Output directory. Note that Output and Publish are different. Output is the intermediate folder, but ...
Read more >Publish doesn't copy Content
I've found that my content is copied fine during builds, but it doesn't get copied to the publish directory. I have the MonoGameContentReference ......
Read more >MSBuild reference for .NET SDK projects
This property is useful if you run dotnet publish on a solution file, as it allows automatic selection of projects that should be...
Read more >ASP.NET Core: Exclude or include files on publish-.net-core
Go to the "Properties" for the file in the "Solution Explorer"; Change the "Copy to Output Directory" property to the desired value ("Copy...
Read more >Top Related Medium Post
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It works for me when I use None instead of Content:
If you want changes to migrate based on this, please file an issue at dotnet/cli, though most people who use aspnetcore packages are web apps and that coupled with emitEntryPoint are the best heuristics we have to identify a web app. I don’t see this changing.
As for the Content None, etc, this was slightly for 1.0.1. Give it a try there and see if it fixed your problem.
If you are still running into issues, please re-activate.