Skip to content

Static web assets breaking change with .razor.js files #34577

@danroth27

Description

@danroth27

In the Picture Fixer sample app there's some custom logic to handle a .razor.js file as a static web asset which appear to be broken now with .NET 6 Preview 7. A .NET 6 Preview 7 version of Picture Fixer can be found here: https://github.com/danroth27/PictureFixer/tree/net6p7.

Here's the custom logic:

  <ItemGroup>
    <!-- Make any .js files in Pages or Shared available as static content -->
    <JavaScriptModules Include="Pages\**\*.js; Shared\**\*.js" RelativePath="%(Identity)" />
    <StaticWebAsset Include="@(JavaScriptModules->'%(FullPath)')" SourceType="" SourceId="$(PackageId)" RelativePath="%(RelativePath)" BasePath="$(StaticWebAssetBasePath)" ContentRoot="$(MSBuildProjectDirectory)" />
  </ItemGroup>
System.InvalidOperationException: Unknown source type '' for 'C:\Users\daroth\Documents\GitHub\SteveSandersonMS\PictureFixer\PictureFixer\Client\Pages\Editor\EditImage.razor.js'.
   at Microsoft.AspNetCore.Razor.Tasks.StaticWebAsset.Validate()
   at Microsoft.AspNetCore.Razor.Tasks.StaticWebAsset.FromTaskItem(ITaskItem item)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at Microsoft.AspNetCore.Razor.Tasks.ComputeReferencedProjectAssets.Execute()

PictureFixer.Client	C:\Program Files\dotnet\sdk\6.0.100-preview.7.21369.19\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets	668	

@javiercn Can you confirm whether this breaking change is intentional?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions