问题描述
根据https://docs.microsoft.com/en-us/dotnet/standard/frameworks sl5
是SDK样式项目支持的目标框架。
我的项目文件是:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;sl5</TargetFrameworks>
</PropertyGroup>
</Project>
但是,我无法构建它:
C:\DataSourceCodeGenerator.Attributes [master ≡ +0 ~1 -0 !]> dotnet build Microsoft (R) Build Engine version 16.7.0+b89cb5fde for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Restored C:\DataSourceCodeGenerator.Attributes\src\DataSourceCodeGenerator.Attributes\DataSourceCodeGenerator.Attributes.csproj (in 176 ms).
C:\Program Files\dotnet\sdk\3.1.401\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(93,5): error NETSDK1013: The TargetFramework value 'sl5' was not recognized. It may be misspelled. If not,then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly. [C:\DataSourceCodeGenerator.Attributes\src\DataSourceCodeGenerator.Attributes\DataSourceCodeGenerator.Attributes.csproj]
DataSourceCodeGenerator.Attributes -> C:\DataSourceCodeGenerator.Attributes\src\DataSourceCodeGenerator.Attributes\bin\Debug\netstandard2.0\DataSourceCodeGenerator.Attributes.dll
Build FAILED.
我可以构建任何Silverlight项目可以识别的目标框架。因此,如果有sl5
的替代方案,那么也可以。
P.S。
请不要问为什么我需要构建一个Silverlight项目。
解决方法
从评论中复制。
Microsoft文档在某些页面中可能不准确,我相信这是此类页面之一。
您不能将.NET Core SDK的默认设置用于多目标Silverlight平台,但是在开源MSBuild.Sdk.Extras
的帮助下,您可以实现相同的目标。