There were before aspdotnet1.0 include/exclude sections on project.json file
{ "exclude": [ "node_modules", "bower_components" ], "publishExclude": [ "**.xproj", "**.user", "**.vspscc" ] } Where is this section in ASP.NET Core 1.1 (there is no project.json)? Are there similar sections on .csproj file or .pubxml?
From documentation: if you wish to specify, for example, some files to get published with your app, you can still use the known mechanisms in
csprojfor that (for example, the<Content>element).
There is a CopyToPublishDirectory attribute for ItemGroup elements that determines whether to copy the file to the publish directory and can have one of the following value:
Note, that there is also similar CopyToOutputDirectory attribute for output folder.
Example (from here):
<ItemGroup> <None Include="notes.txt" CopyToOutputDirectory="Always" /> <!-- CopyToOutputDirectory = { Always, PreserveNewest, Never } --> <Content Include="files\**\*" CopyToPublishDirectory="PreserveNewest" /> <None Include="publishnotes.txt" CopyToPublishDirectory="Always" /> <!-- CopyToPublishDirectory = { Always, PreserveNewest, Never } --> </ItemGroup> If you are interesting how project.json -.csproj migration use CopyToPublishDirectory attribute to migrate publish options, you may look into MigratePublishOptionsRule class in dotnet cli repo.
In .csproj for Visual Studio versions 15.3 and higher, this keeps the files visible in Visual Studio (whereas "Content Remove" does not), and prevents the files from being published.
<ItemGroup> <Content Update="appsettings*.json" CopyToPublishDirectory="Never" /> </ItemGroup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With