我有一个简单的Blazor应用程序。我需要将System.Speech作为项目参考,而这又需要定位.NET Framework 4.6.1。
我按照https://docs.microsoft.com/en-us/dotnet/standard/frameworks上的说明编辑了项目文件。
新的项目文件如下:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netstandard2.0;net461</TargetFramework>
<RestoreAdditionalProjectSources>
https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json;
https://dotnet.myget.org/F/blazor-dev/api/v3/index.json;
</RestoreAdditionalProjectSources>
<LangVersion>7.3</LangVersion>
<RazorLangVersion>3.0</RazorLangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview5-19227-01" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview5-19227-01" PrivateAssets="all" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System.Speech" />
</ItemGroup>
</Project>
当我尝试从Visual Studio运行项目时,出现以下错误:
MSB4018“ ResolvePackageAssets”任务意外失败。
NETSDK1 TargetFramework值'netstandard2.0; net461'无效。要进行多目标定位,请改用“ TargetFrameworks”属性。
有人可以帮忙吗?谢谢
答案 0 :(得分:0)
如果您想使用客户端blazor,则最好对Chrome Speech Synthesis API使用针对Blazor的专用包装器:https://github.com/jsakamoto/Toolbelt.Blazor.SpeechSynthesis