简体   繁体   English

如何将一个 Blazor WASM 项目引用到另一个 Blazor WASM 项目?

[英]How do I reference a Blazor WASM project to another Blazor WASM?

I want Create micro-frontends with Blazor WASM ( base on this article ), I Create two blazor wasm project one name is MicroFrontendsExample.Shell is container/appshell and other name is: MicroFrontendsExample.B1Component我想用 Blazor WASM 创建微前端( 基于这篇文章),我创建了两个 blazor wasm 项目,一个名称是MicroFrontendsExample.Shell是容器/appshell,另一个名称是: MicroFrontendsExample.B1Component

I encountered this error when I referenced the MicroFrontendsExample.B1Component project to the MicroFrontendsExample.Shell我在将MicroFrontendsExample.B1Component项目引用到MicroFrontendsExample.Shell时遇到了这个错误

error:错误:

Severity Code Description Project File Line Suppression State Error Conflicting assets with the same target path '_framework/blazor.boot.json'.严重性代码 说明 项目文件行抑制 State 具有相同目标路径“_framework/blazor.boot.json”的资产冲突错误。 For assets 'Identity: 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' and '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对于资产“身份: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' from different projects. 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.Razor.StaticWebAssets.targets 391 MicroFrontendsExample.Shell C:\Program Files\do.net\sdk\7.0.102\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.884008.14708.WebsetStatics14708

I have no idea, how can I reference blazor wasm to another?我不知道,我怎样才能将 blazor wasm 引用到另一个?

You can set the StaticWebAssetBasePath with different name for each project to distinguish.您可以为每个项目设置不同名称的StaticWebAssetBasePath以进行区分。

In the MicroFrontendsExample.B1Component app's project file ( MicroFrontendsExample.B1Component.csproj ), add a <StaticWebAssetBasePath> property to a <PropertyGroup> with a value of FirstApp to set the base path for the project's static assets:MicroFrontendsExample.B1Component应用程序的项目文件 ( MicroFrontendsExample.B1Component.csproj ) 中,将<StaticWebAssetBasePath>属性添加到值为FirstApp<PropertyGroup>以设置项目的 static 资产的基本路径:

<StaticWebAssetBasePath>FirstApp</StaticWebAssetBasePath>

In the MicroFrontendsExample.Shell app's project file ( MicroFrontendsExample.Shell.csproj ), add a <StaticWebAssetBasePath> property to a <PropertyGroup> with a value of SecondApp :MicroFrontendsExample.Shell应用程序的项目文件 ( MicroFrontendsExample.Shell.csproj ) 中,将<StaticWebAssetBasePath>属性添加到<PropertyGroup>的值为SecondApp

<StaticWebAssetBasePath>SecondApp</StaticWebAssetBasePath>

Note: The name of FirstApp and SecondApp are merely for demonstration purposes.Any base path segments that distinguish the client apps are acceptable.注意: FirstAppSecondApp的名称仅用于演示目的。任何区分客户端应用程序的基本路径段都是可以接受的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM