I\'ve migrated xproj
core projects to csproj
. All is working well, however I still have issues with publish configuration. Based on documentation:
Short answer: use the following snippets instead:
<ItemGroup>
<Content Update="**\*.map;**\*.less;*.json" CopyToPublishDirectory="Never" />
</ItemGroup>
You could also add these patterns to the "DefaultItemExcludes" property.
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);**\*.map;**\*.less;*.json</DefaultItemExcludes>
</PropertyGroup>
Longer answer:
Microsoft.NET.Sdk and Microsoft.NET.Sdk.Web include settings for default items. These are globs for items in your project folder that should always be compiled, embedded, copied to output, etc. There are some settings to control this, but they are not well documented.
If you want to change a metadata value (such as the CopyToPublishDirectory setting ) for an item already included by a default glob, you have to use "Update" instead of "Include".
To see what is happening under the hood, here are the default item settings for Microsoft.NET.Sdk and Microsoft.NET.Sdk.Web
https://github.com/dotnet/sdk/blob/dev15.1.x/src/Tasks/Microsoft.NET.Build.Tasks/build/Microsoft.NET.Sdk.DefaultItems.props#L19-L27
https://github.com/aspnet/websdk/blob/rel/vs2017rtw/src/Web/Microsoft.NET.Sdk.Web.ProjectSystem.Targets/netstandard1.0/Microsoft.NET.Sdk.Web.ProjectSystem.props#L25-L40