Search code examples
c#.net-coresilverlight

How to build an SDK style project for the sl5 target framework?


According to https://learn.microsoft.com/en-us/dotnet/standard/frameworks sl5 is a supported target framework for an SDK style project.

My project file is:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;sl5</TargetFrameworks>
  </PropertyGroup>
</Project>

Yet, I cannot build it:

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.

I am OK to build any target framework that will be recognized by a Silverlight project. So, if there is an alternative to sl5 - that works too.

P.S.

Please, do not ask why I need to build a Silverlight project.


Solution

  • Copied from the comments.

    Microsoft documentation can be inaccurate in certain pages, and I believe this is one of such pages.

    You cannot use .NET Core SDK's default settings to multi target Silverlight platforms, but with some help from the open source MSBuild.Sdk.Extras you can achieve the same.

    References