Skip to content
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

Incorrect static web assets integration #63

Closed
javiercn opened this issue Jul 8, 2024 · 3 comments
Closed

Incorrect static web assets integration #63

javiercn opened this issue Jul 8, 2024 · 3 comments

Comments

@javiercn
Copy link

javiercn commented Jul 8, 2024

Right now this package integrates as follows:

  <Target Name="_ResolveBlazorI18nTextStaticWebAssets" Condition=" $(I18nTextNewStaticWebAssetsArchitecture) " DependsOnTargets="_IncludeGeneratedI18nTextResourceJsons">
    <ItemGroup>
      <_BlazorI18nTextStaticWebAsset Include="@(ContentWithTargetPath)" Condition="$([System.String]::Copy('%(TargetPath)').Replace('/','\').StartsWith('wwwroot\_content\i18ntext\'))" />
      <StaticWebAsset Include="@(_BlazorI18nTextStaticWebAsset)">
        <SourceType>Computed</SourceType>
        <SourceId>$(PackageId)</SourceId>
        <ContentRoot>%(RelativeDir)</ContentRoot>
        <BasePath>/</BasePath>
        <RelativePath>_content/i18ntext/%(FileName)%(Extension)</RelativePath>
        <OriginalItemSpec>%(FullPath)</OriginalItemSpec>
        <AssetKind>All</AssetKind>
        <AssetMode>All</AssetMode>
        <AssetRole>Primary</AssetRole>
      </StaticWebAsset>
    </ItemGroup>
  </Target>

This is problematic because it breaks every time properties are added to static web assets in the SDK on newer versions. If you are generating assets as part of the build, you should instead do something like the snippet below to let static web assets define all the metadata based on the content provided as if it was any other file in the project. This way when we add new metadata your package won't break the pipeline.

<Target Name="MyTarget" BeforeTargets="AssignTargetPaths;ResolveStaticWebAssetsConfiguration">
  <Content Include="dist/**" TargetPath="wwwroot\%(RecursiveDir)%(FileName)%(Extension)" />
</Target>
@jsakamoto
Copy link
Owner

Hi @Junjun-zhao,
I published a new version of the "Blazor I18n Text" NuGet package, ver.13.

https://www.nuget.org/packages/Toolbelt.Blazor.I18nText/13.0.0#releasenotes-body-tab

This version will work with the .NET 9 SDK Preview. Please remember that it is still buggy, especially with the hot-reload, but it will work at least if you rebuild a Blazor project whenever the localized source text files are updated.

@Junjun-zhao
Copy link

Thanks @jsakamoto for your update.
We have tried and it works after upgrade the "Blazor I18n Text" NuGet package to ver.13.

@jsakamoto
Copy link
Owner

Hi @javiercn,

I followed your advice but encountered a problem in the particular case. So, I logged it to an issue: dotnet/sdk#43120.

Could you look into that logged issue? I really appreciate any help you can provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants