![](/img/trans.png)
[英]Microsoft.AspNetCore.Mvc Reference In Project Causes Blazor WASM Issues
[英]How do I reference a Blazor WASM project to another Blazor WASM?
我想用 Blazor WASM 創建微前端( 基於這篇文章),我創建了兩個 blazor wasm 項目,一個名稱是MicroFrontendsExample.Shell是容器/appshell,另一個名稱是: MicroFrontendsExample.B1Component
我在將MicroFrontendsExample.B1Component項目引用到MicroFrontendsExample.Shell時遇到了這個錯誤
錯誤:
嚴重性代碼 說明 項目文件行抑制 State 具有相同目標路徑“_framework/blazor.boot.json”的資產沖突錯誤。 對於資產“身份:C:\Users\Sibetalaee\source\repos\MicroFrontendsExample\MicroFrontendsExample.B1Component\bin\Debug.net7.0\wwwroot_framework\blazor.boot.json,SourceType:Project,SourceId:MicroFrontendsExample.B1Component,ContentRoot C:\Users\Sibetalaee\source\repos\MicroFrontendsExample\MicroFrontendsExample.B1Component\bin\Debug.net7.0\wwwroot, BasePath: /, RelativePath: _framework/blazor.boot.json, AssetKind: Build, AssetMode: All, AssetRole : Primary, RelatedAsset: , AssetTraitName: BlazorWebAssemblyResource, AssetTraitValue: manifest, CopyToOutputDirectory: PreserveNewest, CopyToPublishDirectory: Never, OriginalItemSpec: obj\Debug.net7.0\blazor.boot.json' 和 'Identity: C:\Users\Sibetalaee\source \repos\MicroFrontendsExample\MicroFrontendsExample.Shell\bin\Debug.net7.0\wwwroot_framework\blazor.boot.json,SourceType:Computed,SourceId:MicroFrontendsExample.Shell,ContentRoot:C:\User s\Sibetalaee\source\repos\MicroFrontendsExample\MicroFrontendsExample.Shell\bin\Debug.net7.0\wwwroot, BasePath: /, RelativePath: _framework/blazor.boot.json, AssetKind: Build, AssetMode: All, AssetRole: Primary, RelatedAsset: , AssetTraitName: BlazorWebAssemblyResource, AssetTraitValue: manifest, CopyToOutputDirectory: PreserveNewest, CopyToPublishDirectory: Never, OriginalItemSpec: obj\Debug.net7.0\blazor.boot.json' 來自不同的項目。 MicroFrontendsExample.Shell C:\Program Files\do.net\sdk\7.0.102\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.884008.14708.WebsetStatics14708
我不知道,我怎樣才能將 blazor wasm 引用到另一個?
您可以為每個項目設置不同名稱的StaticWebAssetBasePath
以進行區分。
在MicroFrontendsExample.B1Component
應用程序的項目文件 ( MicroFrontendsExample.B1Component.csproj
) 中,將<StaticWebAssetBasePath>
屬性添加到值為FirstApp
的<PropertyGroup>
以設置項目的 static 資產的基本路徑:
<StaticWebAssetBasePath>FirstApp</StaticWebAssetBasePath>
在MicroFrontendsExample.Shell
應用程序的項目文件 ( MicroFrontendsExample.Shell.csproj
) 中,將<StaticWebAssetBasePath>
屬性添加到<PropertyGroup>
的值為SecondApp
:
<StaticWebAssetBasePath>SecondApp</StaticWebAssetBasePath>
注意: FirstApp
和SecondApp
的名稱僅用於演示目的。任何區分客戶端應用程序的基本路徑段都是可以接受的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.