Unable to exclude JSON files from being copied to the output directory with `blazorwasm` template
See original GitHub issueIssue Description
So there’s a project that combines Blazor and some NPM scripts, therefore there’s two NPM files (package.json and package-lock.json) in the source code folder. The problem is - these files are getting copied over to the build directory, and whatever I do to exclude them - nothing helps. These files shouldn’t be in the output directory, since they’re only to be used by developers. The problem reproduces with clean project created from blazorwasm
template, but doesn’t reproduce for the console
one.
I’ve tried these two ways to exclude it, but unsuccessfully:
.csproj file
<ItemGroup>
<None Include="package.json" />
</ItemGroup>
<ItemGroup>
<ExcludeFromPackageFiles Include="package.json" />
</ItemGroup>
it looks like any .json file despite being unused is somehow copied to the bin directory.
I’m curious if this is a bug, and if not how it can be switched off.
Steps to Reproduce
- Create a new project with
dotnet new blazorwasm
- Create a new empty .json file in the root of the repo, for example: package.json
- Run
dotnet build
and notice that the file was copied tobin/Debug/net6.0
Versions & Configurations
- dotnet version
6.0.300
- OS: Debian GNU/Linux bookworm/sid
- Kernel: Linux 5.17.0-1-amd64
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Found multiple publish output files with the same relative ...
Solution #2: Exclude the problematic files to be copied to the output folder. In this example we'll exclude these files: compilerconfig.json and ...
Read more >Host and deploy ASP.NET Core Blazor WebAssembly
Learn how to host and deploy Blazor WebAssembly using ASP.NET Core, Content Delivery Networks (CDN), file servers, and GitHub Pages.
Read more >Blazor WASM app won't load after publish. Works fine on ...
The bin/obj folders from your solution. This folders dont appear in the solution itself you need to manually go to the folder of...
Read more >Debug ASP.NET Core Blazor WebAssembly
Learn how to debug Blazor WebAssembly with browser developer tools and an integrated development environment (IDE).
Read more >Blazor WebAssembly & Web API on .NET 6 – Full Course (C#)
Check out his channel: https://www.youtube.com/c/GavinLon Code: ... Resources ⭐️ Copy Seed Data from GitHub: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
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
Is it a deliberate choice to copy all .json files from
src/
directory to the output folder? I would imagine that an opt-in approach (include what’s needed) is safer here than opt-out (exclude what’s not needed) just because most people wouldn’t know about it, unless they check the output.Content Remove works, but for tsconfig.json, removing the config file, breaks the typescript compiler - as it is unable to find the config file. The following seems to be a better solution: