When using the MSBuild package with Blazor library extra content files are added to nupkg
See original GitHub issueBug Report
When using the Microsoft.Typescript.MSBuild
4.2.1-rc to pack a Blazor Library project for nuget package, the compiled javascript files are added to the content
and contentFiles
folders of the nuget package, not just to staticWebAssets
that Blazor build picks up.
GetTypeScriptOutputForPublishing
MSBuild target seems to be the source of errors, if the content of that target is commented out, the nuget package does not have the above problem.
UPDATE
The real sideeffects of this coming to the surface when the build nuget package is consumed in another Blazor project and being built in VS 2019 16.x. As the JS files are showing up in the consuming project as project items and they should not. The worse thing is that if you put a tsconfig.json into the Logging package no matter if it is a <None....
item, that will also be packed and will cause compilation failure in the consuming project as there will be no source files to compile (that’s how we started to notice this problem).
Repro
- Clone https://github.com/BlazorExtensions/Logging
- dotnet pack
- Observe the contents of the nupkg file
🔎 Search Terms
msbuild, nuget, blazor
🙁 Actual behavior
See in summary above.
🙂 Expected behavior
Nuget package should not have those extra files.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top GitHub Comments
@attilah so I don’t know how much you’re going to like this, but one workaround I found is to override the offending target by adding this to your
Directory.Build.targets
:Still should investigate the inner workings of this and find out how we can integrate better with Blazor though.
Any news on this? It is still an issue with Blazor 6, .NET 6 and/or VS 2022. I just stumbled across this and took me a while to figure this out …
EDIT: The workaround mentioned is not working anymore. On .NET 6 you have to first run
dotnet build
and afterwardsdotnet pack
. That way it is going to be build twice but the files are not added to the NuGet package.Do not try to add
--no-build
todotnet pack
- that does not work because of https://github.com/dotnet/aspnetcore/issues/40317#issuecomment-1048254393.