jsakamoto / Toolbelt.Blazor.I18nText

The class library that provides the ability to localize texts on your Blazor app!
Mozilla Public License 2.0
246 stars 23 forks source link

Stopped working after upgrading to .NET 6 Preview 7 & RC 1 #41

Closed taketwopayone closed 2 years ago

taketwopayone commented 3 years ago

Upgraded the project to .NET 6 Preview 7 and suddenly it shows the JSON key instead of the actual value. Worked perfectly before the update to .NET 6 Preview 7 (including Preview 6)

jsakamoto commented 3 years ago

@taketwopayone Thank you for your feedback!

I'm going to figure out the problem that you reported and going to resolve it.

jsakamoto commented 3 years ago

I did not resolve this issue yet (it's in progress), but I found a workaround at this time.

for Blazor WebAssembly stand-alone projects:

Try to downgrade the version of the "Microsoft.AspNetCore.Components.WebAssembly.DevServer" package referencing in your project to v.6.0.0-preview.6.21355.2.

<!-- your .csproj file -->
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-preview.7.21378.6" />
    <!-- 👇 downgrade this! -->
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-preview.6.21355.2" PrivateAssets="all" />
    ...

This downgrading should be safe yet in the .NET 6 SDK preview 7.

for Blazor WebAssembly ASP.NET Core hosted projects:

Try to insert some code snippets as below into the Startup class in an ASP.NET Core host server.

// your Startup.cs file
public class Startup
{
  ...
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  {
    // 👇 Insert this at the top of the "Configure" method!
    var assembly = Assembly.Load(env.ApplicationName);
    var basePath = (string.IsNullOrEmpty(assembly.Location) ? AppContext.BaseDirectory : Path.GetDirectoryName(assembly.Location));
    env.WebRootFileProvider = new CompositeFileProvider(
      new PhysicalFileProvider(Path.Combine(basePath, "wwwroot")),
      env.WebRootFileProvider);
    ...

The code snippets above should be safe and should have no harmful side effects.

Anyway, I'm working to resolve this issue completely. It should be no need for any workarounds finally.

jsakamoto commented 3 years ago

[The Progress Report]

I'm doing that add support for .NET 6 Preview 7, but I found it is not easy work. This problem is caused by the changes in static web assets' implements from preview 6 to 7.

I believe I can do it, but it will take more days.

Fortunately, there is a workaround at this time, so please wait for more days to resolve this problem.

P.S. I'll apply the other improvement and publish a new version before I finished resolving this issue. I appreciate your understanding.

taketwopayone commented 3 years ago

I have implemented the workaround you posted and it works great in .NET 6 Preview 7.

Thank you very very much for your outstanding work on this and your other Blazor related libraries. Highly appreciated!

jsakamoto commented 3 years ago

It took so many days, but finally, I released version 11 preview 1 to support .NET 6 preview 7.

The ver.11 should work fine also on .NET 6 preview 7. Please try it out. 😄

Tommatheussen commented 3 years ago

Using the workaround listed above makes it work. Sadly using the version 11 preview 1 doesn't seem to work for me. I also tried creating a new Blazor WASM ASPNET Core hosted application and adding it in there, same results, the .json files fail to load and all return 404

jsakamoto commented 3 years ago

@Tommatheussen

Could you try to build and run the project "Net6WasmHosted" which I attached below?

In my environment, it works as I expected.

image

I want to know the project "Net6WasmHosted" also doesn't work in your environment or not.

Tommatheussen commented 3 years ago

Hi @jsakamoto, I quickly tried running the project, and I got the same results as my own projects: image

I am currently running macOS, not sure if that makes a difference or not, I am currently setting up a virtual windows environment to check if that makes a different, will report when I know more

Tommatheussen commented 3 years ago

So, this is interesting, it works as expected on a windows virtual machine. To completely rule out whether or not this is just an issue with my macOS setup, I'll get a clean macOS VM up and running and try running it in there as well

jsakamoto commented 3 years ago

I am currently running macOS,

Oh, It might be an essential point at this problem.

.NET 6 Preview 7 SDK is very unstable, particularly static web assets manipulation, so I currently expect that .NET 6 RC1 SDK will fix all kinds of static web assets problems.

I recommend that we should retry that when after .NET 6 RC1 SDK is released.

Anyway, thank you for your feedback, and I want to support any platform finally.

P.S. If I can make the time, I'll investigate this problem on Linux.

Tommatheussen commented 3 years ago

I've noticed the transition from preview 6 to 7 didn't go smoothly for a lot of our packages. Hopefully RC1 will improve a lot.

A clean macOS VM has the same issue so it's clearly a macOS specific issue. As mentioned above, the workaround works perfectly fine for us for now, we'll revisit when RC1 is released. Btw, thanks for all the efforts so far :)

jsakamoto commented 2 years ago

[Progress Report]

The .NET 6 RC1 SDK broke the build script of this package again.😢

Currently, this package will not work well under the .NET 6 RC1 SDK not only on Linux but also on Windows OS.

I'm still working on adding support for .NET 6 RC1 SDK.

jsakamoto commented 2 years ago

The .NET 6 RC1 support was very tough work for me, and it took a long time, but finally, I achieved that.

Would you please try out the latest preview version of the "Blazor I18n Text" NuGet package ver.11 preview 2?

Tommatheussen commented 2 years ago

@jsakamoto it took me a while to get back to our project using this library, sorry for the delay.

I can confirm the library works with the latest RC2 release 🥳 thank you for the effort! 👍