在 .NET6 Blazor Webassembly 应用程序中使用外部程序集构建错误

Build Error with External Assembly in .NET6 Blazor Webassembly App

我正在尝试使用 Visual Studio 2022(预览版)使用 .Net6 创建 Blazor Webassembly 应用程序。我在该项目中引用了外部程序集文件。当我构建项目时,出现以下错误,

The asset 'D:\Office\Testing\BlazorApp1\BlazorApp1\bin\Debug\net6.0\wwwroot_framework\ClassLibrary1.dll' can not be found at any of the searched locations 'D:\Office\Testing\BlazorApp1\BlazorApp1\bin\Debug\net6.0\wwwroot_framework\ClassLibrary1.dll' and 'ClassLibrary1'

screen shot image

有解决办法吗?

项目的属性在这里

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.0-rc.1.21452.15" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.0-rc.1.21452.15" PrivateAssets="all" />
  </ItemGroup>

  <ItemGroup>
    <Reference Include="ClassLibrary1">
      <HintPath>Lib\ClassLibrary1.dll</HintPath>
      <EmbedInteropTypes></EmbedInteropTypes>
    </Reference>
  </ItemGroup>

  <ItemGroup>
    <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
  </ItemGroup>

</Project>

你只需要改变这个,

<ItemGroup>
   <Reference Include="../Lib/ClassLibrary1">
     <HintPath>Lib\ClassLibrary1.dll</HintPath>
     <EmbedInteropTypes></EmbedInteropTypes>
   </Reference>   
</ItemGroup>