Add a target for netstandard2.0 (dotnet/core-setup#4586)
authorEric Erhardt <eric.erhardt@microsoft.com>
Thu, 20 Sep 2018 16:45:29 +0000 (11:45 -0500)
committerGitHub <noreply@github.com>
Thu, 20 Sep 2018 16:45:29 +0000 (11:45 -0500)
* Add a target for netstandard2.0

Adding netstandard2.0 TFMs to the PlatformAbstractions and DependencyModel libraries so we don't force users to bring down unnecessary dependencies.

Fix dotnet/core-setup#3680

* Add a comment explaining the Newtonsoft.Json versioning reasoning.

Commit migrated from https://github.com/dotnet/core-setup/commit/2c99636fa3b1d38c773a18b8d325c865c1804629

src/installer/managed/CommonManaged.props
src/installer/managed/Microsoft.DotNet.PlatformAbstractions/Microsoft.DotNet.PlatformAbstractions.csproj
src/installer/managed/Microsoft.Extensions.DependencyModel/Microsoft.Extensions.DependencyModel.csproj
src/installer/test/Microsoft.Extensions.DependencyModel.Tests/Microsoft.Extensions.DependencyModel.Tests.csproj

index 2a62fe2..a442d51 100644 (file)
@@ -6,7 +6,6 @@
     <VersionPrefix>$(MajorVersion).$(MinorVersion).$(PatchVersion)</VersionPrefix>
     <AssemblyFileVersion>$(VersionPrefix)</AssemblyFileVersion>
     <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
-    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
     <IncludeSymbols>true</IncludeSymbols>
     <Serviceable>true</Serviceable>
     <PackageLicenseUrl>https://github.com/dotnet/core-setup/blob/master/LICENSE.TXT</PackageLicenseUrl>
     <PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
   </PropertyGroup>
 
+  <PropertyGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
+    <DisableImplicitFrameworkReferences>true</DisableImplicitFrameworkReferences>
+  </PropertyGroup>
+
   <PropertyGroup>
     <RepositoryType>git</RepositoryType>
     <RepositoryUrl>git://github.com/dotnet/core-setup</RepositoryUrl>
index 354d20b..b7e6974 100644 (file)
@@ -3,8 +3,8 @@
 
   <PropertyGroup>
     <Description>Abstractions for making code that uses file system and environment testable.</Description>
-    <TargetFrameworks>net45;netstandard1.3</TargetFrameworks>
-    <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'" >netstandard1.3</TargetFrameworks>
+    <TargetFrameworks>net45;netstandard1.3;netstandard2.0</TargetFrameworks>
+    <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'" >netstandard1.3;netstandard2.0</TargetFrameworks>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
 
@@ -17,9 +17,7 @@
     <PackageReference Include="System.Runtime.Extensions" Version="4.1.0" />
     <PackageReference Include="System.Runtime.InteropServices" Version="4.1.0" />
   </ItemGroup>
-  <ItemGroup>
+  <ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
     <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.0.0" />
   </ItemGroup>
-
-
 </Project>
index c05bac3..965fe08 100644 (file)
@@ -3,13 +3,32 @@
 
   <PropertyGroup>
     <Description>Abstractions for reading `.deps` files.</Description>
-    <TargetFrameworks>net451;netstandard1.3;netstandard1.6</TargetFrameworks>
-    <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.3;netstandard1.6</TargetFrameworks>
+    <TargetFrameworks>net451;netstandard1.3;netstandard1.6;netstandard2.0</TargetFrameworks>
+    <TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.3;netstandard1.6;netstandard2.0</TargetFrameworks>
   </PropertyGroup>
 
+  <Choose>
+    <!--
+    Newtonsoft.Json v11.0.1 is the first verison that targets netstandard2.0. Since we added a target for netstandard2.0
+    so users aren't forced to download the 1.x dependencies, it makes sense to use this version of Newtonsoft.Json.
+    However, we still use the previous (v9.0.1) for other TFMs, so existing users don't need to upgrade their Newtonsoft.Json.
+    For example, the SDK targets net4x and is loaded in VS, so it can't upgrade to a new Newtonsoft.Json.
+    -->
+    <When Condition="'$(TargetFramework)' == 'netstandard2.0'">
+      <PropertyGroup>
+        <NewtonsoftJsonPackageVersion>11.0.1</NewtonsoftJsonPackageVersion>
+      </PropertyGroup>
+    </When>
+    <Otherwise>
+      <PropertyGroup>
+        <NewtonsoftJsonPackageVersion>9.0.1</NewtonsoftJsonPackageVersion>
+      </PropertyGroup>
+    </Otherwise>
+  </Choose>
+
   <ItemGroup>
     <ProjectReference Include="..\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />
-    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
+    <PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonPackageVersion)" />
   </ItemGroup>
 
   <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' Or '$(TargetFramework)' == 'netstandard1.6' ">
index 6864bf6..5f21058 100644 (file)
@@ -18,7 +18,6 @@
     <PackageReference Include="Microsoft.DotNet.InternalAbstractions" Version="1.0.0" />
     <PackageReference Include="FluentAssertions" Version="4.19.4" />
     <PackageReference Include="Moq" Version="4.7.142" />
-    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
     <PackageReference Include="NuGet.Versioning" Version="4.0.0" />
     <PackageReference Include="Microsoft.DotNet.ProjectModel" Version="1.0.0-rc2-002702" />
     <ProjectReference Include="..\..\managed\Microsoft.DotNet.PlatformAbstractions\Microsoft.DotNet.PlatformAbstractions.csproj" />