question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to exclude JSON files from being copied to the output directory with `blazorwasm` template

See original GitHub issue

Issue 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

  1. Create a new project with dotnet new blazorwasm
  2. Create a new empty .json file in the root of the repo, for example: package.json
  3. Run dotnet build and notice that the file was copied to bin/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:open
  • Created a year ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
arsinclaircommented, May 23, 2022

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.

0reactions
mediabuffcommented, May 17, 2023

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:

<Content Update="package*.json" CopyToOutputDirectory="Never"/>
<Content Update="libman.json" CopyToOutputDirectory="Never"/>
<Content Update="tsconfig.json" CopyToOutputDirectory="Never"/>
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found