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

GET _content/Toolbelt.Blazor.I18nText/script.min.js net::ERR_ABORTED 404 #21

Closed Safirion closed 4 years ago

Safirion commented 4 years ago

Hi,

When I generate my project with Toolbelt.Blazor.I18nText 7.1.0 script.min.js is not generated cf this screenshot : image

Any suggestion ?

jsakamoto commented 4 years ago

Sorry to late reply!

At build time, the "script.min.js" file is not deployed in the output folder such as under the "bin" folder. Instead, StaticFIleMiddleware of ASP.NET Core provides the "script.min.js" file from NuGet package cache folder.

You will find some "....StaticWebAssets.xml" files in the output folder. Those files describe the locations of static web asset files bundled with NuGet packages. StaticFIleMiddleware of ASP.NET Core reads this WebAssets.xml to provide those web asset files via request URL.

See also: "What are ASP.NET Core Static Web Assets? - stack overflow" https://stackoverflow.com/questions/58436497/what-are-asp-net-core-static-web-assets

Despite these mechanisms, it means other trouble would happen that you encountered the HTTP 404 not found error for the "script.min.js".

Could you provide the project file "Support.Web.csproj" and the source file "Program.cs" for I look into it? You can embed any files to this issue via drag & drop operation.

Safirion commented 4 years ago

Hello @jsakamoto,

No problem ahah 😉

In fact, this issue seems to be resolved... I had use a workaround these days by copying script.min.js from another of my projects that using this nugget package. And today, when I try to reproduce this bad behaviour by deleting bin/obj content : I can't. Maybe a bug of Visual Studio 2019 precedent Previews... Don't know....

So, I close this issue, thank you for your reply and thank you for this great package 😁

Safirion commented 4 years ago

Ok, I had forgot that I put the script.min.js (workaround) in wwwroot/_content/Toolbelt.Blazor.I18nText/script.min.js and not in bin/obj folders . So after removing it, the issue reapear immediatly....

This is my support.web.csproj/startup.cs/program.cs : Support.Web.zip

jsakamoto commented 4 years ago

Hum... I could not reproduce the problem.

I embed the project files based on your project that includes bin and obj folders for reference.

Support.Web (2).zip

Question:

Is the script file "%USERPROFILE%.nuget\packages\toolbelt.blazor.i18ntext\7.1.0\staticwebassets\script.min.js" exists in your develop environment?

Safirion commented 4 years ago

Hi, I have download your zip and I can reproduce my problem by modifying Property/launchSettings.json with same data as my project :

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:50991",
      "sslPort": 44381
    }
  },
  "profiles": {
    "Support.Web (PreProduction)": {
      "commandName": "IISExpress",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "PreProduction",
        "ASPNETCORE_HTTPS_PORT": "44381"
      }
    },
    "Support.Web (Production)": {
      "commandName": "IISExpress",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Production",
        "ASPNETCORE_HTTPS_PORT": "44381"
      }
    }
  }
}
jsakamoto commented 4 years ago

Oh! you have to set ASPNETCORE_ENVIRONMENT to "Development" to run your Blazor Server app before publish, especially that app is referencing packages which include static web assets.

image

This is by design of "ASP.NET Core Static Web Assets" mechanism.

Safirion commented 4 years ago

Ok thank you for the reply :) If it's by design, I will change my environment name.