如何为sl5目标框架构建SDK风格的项目



根据https://learn.microsoft.com/en-us/dotnet/standard/frameworkssl5是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.AttributessrcDataSourceCodeGenerator.AttributesDataSourceCodeGenerator.Attributes.csproj (in 176 ms).
C:Program Filesdotnetsdk3.1.401SdksMicrosoft.NET.SdktargetsMicrosoft.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.AttributessrcDataSourceCodeGenerator.AttributesDataSourceCodeGenerator.Attributes.csproj]
DataSourceCodeGenerator.Attributes -> C:DataSourceCodeGenerator.AttributessrcDataSourceCodeGenerator.AttributesbinDebugnetstandard2.0DataSourceCodeGenerator.Attributes.dll
Build FAILED.

我可以构建任何将被Silverlight项目识别的目标框架。因此,如果有sl5的替代方案,那也是可行的。

p.S.

请不要问我为什么需要构建Silverlight项目。

从注释中复制。

Microsoft文档在某些页面中可能不准确,我相信这就是其中之一。

您不能将.NET Core SDK的默认设置用于多目标Silverlight平台,但在开源MSBuild.Sdk.Extras的帮助下,您可以实现同样的设置。

参考文献

  • https://github.com/dotnet/sdk/issues/8779
  • https://github.com/novotnyllc/MSBuildSdkExtras

最新更新