Skip to content

Using a Razor Component Library with TypeScript fails to copy assets #57662

Open
@FreyLuis

Description

@FreyLuis

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a Razor Component Library that includes some TypeScript files. The component library is referenced in a Blazor WebAssembly web app. My problem is that the generated files aren't included as static web assets when publishing.
The problem has been a topic of other issues over the years (#12646, #13122, dotnet/sdk/issues/19474), but I currently can't get it to work.

I made a small solution that recreates the issue: https://github.com/FreyLuis/TypeScript.MsBuild.TestApp
When running the following commands, the compiled typescript files are not included in the published output:

dotnet clean
dotnet publish .\TypeScript.MsBuild.TestApp\

I tried the solution that is documented here, but I'm getting an exception when I'm trying to publish it.

C:\Program Files\dotnet\sdk\8.0.400\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(507,5): error : Two assets found targeting the same path with incompatible asset kinds

I pushed the broken fix to the fix-from-documentation branch. I also deleted the tsconfig to get closer to the documentation, even though my goal would be to use a tsconfig.
I also tried using Microsoft.TypeScript.MSBuild 5.6.0-beta, which didn't help.

I would appreciate any help with this, thank you in advance.

Expected Behavior

It should work

Steps To Reproduce

Exceptions (if any)

C:\Program Files\dotnet\sdk\8.0.400\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(507,5): error : Two assets found targeting the same path with incompatible asset kinds:  [C:\Users\luis\source\demos\TypeScript.MsBuild.TestApp\RazorClassLibrary\RazorClassLibrary.csproj]
C:\Program Files\dotnet\sdk\8.0.400\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(507,5): error : 'C:\Users\luis\source\demos\TypeScript.MsBuild.TestApp\RazorClassLibrary\wwwroot\Counter.js' with kind 'All' [C:\Users\luis\source\demos\TypeScript.MsBuild.TestApp\RazorClassLibrary\RazorClassLibrary.csproj]
C:\Program Files\dotnet\sdk\8.0.400\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(507,5): error : 'C:\Users\luis\source\demos\TypeScript.MsBuild.TestApp\RazorClassLibrary\wwwroot\Counter.js' with kind 'All' [C:\Users\luis\source\demos\TypeScript.MsBuild.TestApp\RazorClassLibrary\RazorClassLibrary.csproj]
C:\Program Files\dotnet\sdk\8.0.400\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.targets(507,5): error : for path 'Counter.js' [C:\Users\luis\source\demos\TypeScript.MsBuild.TestApp\RazorClassLibrary\RazorClassLibrary.csproj]

.NET Version

8.0.400

Anything else?

.NET SDK:
Version: 8.0.400
Commit: 36fe6dda56
Workload version: 8.0.400-manifests.56cd0383
MSBuild version: 17.11.3+0c8610977

Runtime Environment:
OS Name: Windows
OS Version: 10.0.22631
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\8.0.400\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
[wasm-tools]
Installation Source: VS 17.12.35209.166, VS 17.11.35222.181
Manifest Version: 8.0.8/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.workload.mono.toolchain.current\8.0.8\WorkloadManifest.json
Install Type: FileBased

[aspire]
Installation Source: VS 17.12.35209.166, VS 17.11.35222.181
Manifest Version: 8.1.0/8.0.100
Manifest Path: C:\Program Files\dotnet\sdk-manifests\8.0.100\microsoft.net.sdk.aspire\8.1.0\WorkloadManifest.json
Install Type: FileBased

Host:
Version: 9.0.0-preview.7.24405.7
Architecture: x64
Commit: static

.NET SDKs installed:
8.0.400 [C:\Program Files\dotnet\sdk]
9.0.100-preview.7.24407.12 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 9.0.0-preview.7.24406.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 9.0.0-preview.7.24405.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.33 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 8.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 9.0.0-preview.7.24405.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
C:\Users\luis\source\global.json

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.area-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions