Skip to content

Blazor 6 : "Microsoft.TypeScript.MSBuild" and a collocated JavaScript file with a .razor file cause a build error on the Ubuntu #40640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jsakamoto opened this issue Mar 9, 2022 · 7 comments
Labels
area-blazor Includes: Blazor, Razor Components External This is an issue in a component not contained in this repository. It is open for tracking purposes. feature-static-web-assets

Comments

@jsakamoto
Copy link

jsakamoto commented Mar 9, 2022

Describe the bug

On the Ubuntu Linux 20.04 LTS, for a Blazor WebAssembly project (.NET 6) with the following conditions, 2nd time or later of execution, dotnet build command causes the build error "Two assets found targeting the same path with incompatible asset kinds".

  • The project references "Microsoft.TypeScript.MSBuild" NuGet package.
  • The project contains .razor.js files that are collocated with .razor files.
  • The project also contains .razor.ts files, and they are transpiled to the .razor.js files above.

Notice:

  • I encountered this problem with the .NET SDK 6.0.x on Ubuntu Linux 20.04 LTS on WSL2 on my Windows 11 Pro 21H2 x64, and GitHub Actions of ubuntu-latest.
  • The build error never occurred on Windows OS. (I don't know the case on a macOS because I could not try it on macOS.)
  • The 1st execution of the dotnet build was completed successfully whether runs on Ubuntu or Windows.
  • It seems the error happens only when the transpiled .razor.js files already exist before the build has been started.
  • If I do not use TypeScript for collocated JavaScript with Razor component, the build error never occurred even though I continue using TypeScript for located JavaScript under the "wwwroot" folder.
  • At that time, I used "Microsoft.TypeScript.MSBuild" NuGet package version 4.6.2, but in my case, the build error seems to happen even another version of "Microsoft.TypeScript.MSBuild" NuGet package such as version 3.x.

To Reproduce

Requirements

Steps to reproduce

  1. Open a terminal on the Ubuntu Linux 20.04 LTS.
  2. Change the current directory to where you extracted the "BlazorCollocateJsWithRazor-net-sdk-6.0.201.zip" file.
  3. Execute dotnet build command and confirm it will be a success.
  4. Execute dotnet build command one more time, then you will see the build error.

Exceptions (if any)

The build error message is below:

/usr/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.JSModules.targets(95,5): error : Two assets found targeting the same path with incompatible asset kinds:  [/mnt/c/Projects/Blazor/Trials/BlazorCollocateJsWithRazor/BlazorCollocateJsWithRazor.csproj]
/usr/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.JSModules.targets(95,5): error : '/mnt/c/Projects/Blazor/Trials/BlazorCollocateJsWithRazor/App.razor.js' with kind 'All' [/mnt/c/Projects/Blazor/Trials/BlazorCollocateJsWithRazor/BlazorCollocateJsWithRazor.csproj]
/usr/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.JSModules.targets(95,5): error : '/mnt/c/Projects/Blazor/Trials/BlazorCollocateJsWithRazor/App.razor.js' with kind 'All' [/mnt/c/Projects/Blazor/Trials/BlazorCollocateJsWithRazor/BlazorCollocateJsWithRazor.csproj]
/usr/share/dotnet/sdk/6.0.201/Sdks/Microsoft.NET.Sdk.Razor/targets/Microsoft.NET.Sdk.Razor.JSModules.targets(95,5): error : for path 'App.razor.js' [/mnt/c/Projects/Blazor/Trials/BlazorCollocateJsWithRazor/BlazorCollocateJsWithRazor.csproj]

Further technical details

dotnet --info

.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         ubuntu.20.04-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.201/

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  5.0.406 [/usr/share/dotnet/sdk]
  6.0.201 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 5.0.15 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 5.0.15 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
@jsakamoto jsakamoto changed the title "Microsoft.TypeScript.MSBuild" and a collocated JavaScript file with a .razor file cause a build error on the Ubuntu Blazor 6 : "Microsoft.TypeScript.MSBuild" and a collocated JavaScript file with a .razor file cause a build error on the Ubuntu Mar 9, 2022
@mkArtakMSFT
Copy link
Contributor

Thanks for contacting us.
This seems to be caused by the fact that you're copying assets to the wwwroot folder. This blogpost should help you with resolving this issue: https://devblogs.microsoft.com/dotnet/build-client-web-assets-for-your-razor-class-library/

We plan to productize the feature referenced in the blog post and make it part of the framework in .NET 7: #40572

@mkArtakMSFT mkArtakMSFT transferred this issue from dotnet/sdk Mar 10, 2022
@mkArtakMSFT mkArtakMSFT added area-blazor Includes: Blazor, Razor Components feature-static-web-assets Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Mar 10, 2022
@ghost
Copy link

ghost commented Mar 10, 2022

Hi @jsakamoto. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.

@mkArtakMSFT mkArtakMSFT added this to the .NET 7 Planning milestone Mar 10, 2022
@ghost
Copy link

ghost commented Mar 10, 2022

Thanks for contacting us.

We're moving this issue to the .NET 7 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@jsakamoto
Copy link
Author

@mkArtakMSFT Thank you for replying.

However, sorry to bother you, but... I was too disappointed with that reply, and I've felt really sad due to the careless attitude of that reply. 😢

I understand well that the product development team is very busy, and therefore, it is needed to prioritize so many issues.
So I would not mind if this issue is made a low priority.

However, I've felt that you have read my post with a careless attitude.

  • The sample project that I provided includes copying assets to the wwwroot folder, but it doesn't matter for this issue. The purpose of that is just for proof that copying assets to the wwwroot folder don't matter for this issue. In fact, after removing the App.razor.ts, building on both Linux and Windows will be a success even though the project still includes copying assets to the wwwroot folder.
  • This issue looks depends on the OS platform deeply. In my investigation, this problem happens only on Linux OS never happens on Windows OS.
  • This issue also looks to depend on collocated JavaScript files with Razor Component files since .NET 6, too. (as I said previously, JavaScript files that are copying to the wwwroot folder don't cause the build error in this scenario.)
  • I understand that the reason for this problem might be the "Microsoft.TypeScript.MSBuild" package side, not the .NET SDK side.
  • In my opinion, at this time, the pieces of evidence above tell us that the blog post you introduced may not be involved with this issue, I think.

I apologize if I don't understand that you might not be able to spend enough time understanding my post because you are so busy. 🙇
However, I appreciate it if you or your team try to investigate well this issue again.

Anyway, I hope this post would be helpful to save the developers working on Linux OS and reduce the people who feel "I don't like .NET platform due to often happening such a build error". ❤️

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Mar 12, 2022
@javiercn
Copy link
Member

javiercn commented Mar 14, 2022

@jsakamoto we apologize if you thought we didn't pay close attention to your issue.

We normally comb through dozens of issues on a weekly basis and this is an issue that we've seen in the past, so our first action was to point out the common answer we give people in these situations.

It normally happens because people put the outputs from the build into the things that are considered for inputs and doing so breaks incrementalism.

In this case, it seems that the source of the issue is different as per the details below:

I took a second look at your issue and it seems to be caused by the TypeScript MSBuild tasks adding additional content items on Linux for some reason as opposed to windows where it does not:
image
image

The issue seems to come from the GetTypeScriptOutputForPublishing producing different results on Linux and on Windows, so on Linux the content is added twice.

@danroth27 can you forward this issue to the TS folks?

@javiercn javiercn added External This is an issue in a component not contained in this repository. It is open for tracking purposes. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Mar 14, 2022
@javiercn
Copy link
Member

Filed an issue on TypeScript to track this problem here

@jsakamoto
Copy link
Author

@javiercn Thank you for your sincere reply and for investigating this issue.

We normally comb through dozens of issues on a weekly basis

I can imagine it must be too much tough work.
So I always appreciate the product development team. ❤️

Sorry to bother you, but getting the reply "We are still triaging", "Wait for more time" or "We don't have enough time" might be better for me than getting a reply "It seems the same as a common issue" without well investigating.

caused by the TypeScript MSBuild tasks adding additional content items on Linux

Yes, I feel so too.

Just curious, I feel strange that the wwwroot/Helper.js does not cause the build error even though it is also translated from the wwwroot/Helper.ts by the TypeScript MSBuild task like the App.razor.js.

image

image

Anyway, I do not mind if there is no reply to this comment.
I just hope somebody will resolve this problem in the future.

Filed an issue on TypeScript to track this problem here

Many thanks for your reaction.
Again, thank you for your effort to resolve this scenario.

@ghost ghost locked as resolved and limited conversation to collaborators Apr 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-blazor Includes: Blazor, Razor Components External This is an issue in a component not contained in this repository. It is open for tracking purposes. feature-static-web-assets
Projects
None yet
Development

No branches or pull requests

3 participants