Move some projects to netstandard2.0 (#8692)

* Move some projects to netstandard2.0

* Use version agnostic $(TargetFrameworkIdentifier) property to make changing versions easier since we only care about .NET Framework vs .NET Standard
* Add missing project to solution file
* Update TestPackageProjects.targets to use netstandard2.0 on non-Windows
This commit is contained in:
Jeff Kluge 2018-02-27 13:59:59 -08:00 committed by Livar Cunha
parent c4cae059a9
commit 8d7009cb83
13 changed files with 31 additions and 24 deletions

View file

@ -39,7 +39,7 @@
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<VersionSuffix>$(VersionSuffix)</VersionSuffix>
<Clean>False</Clean>
<MsbuildArgs>/p:TargetFramework=netstandard1.5</MsbuildArgs>
<MsbuildArgs>/p:TargetFramework=netstandard2.0</MsbuildArgs>
</BaseTestPackageProject>
<BaseTestPackageProject Include="src/Microsoft.DotNet.InternalAbstractions">
<Name>Microsoft.DotNet.InternalAbstractions</Name>

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Description>SLN file reader/writer</Description>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netstandard1.6</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<DebugType>portable</DebugType>
<AssemblyName>Microsoft.DotNet.Cli.Sln.Internal</AssemblyName>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
@ -23,7 +23,7 @@
<ItemGroup>
<PackageReference Include="System.Collections.Specialized" Version="4.0.1" />
<PackageReference Include="System.Text.RegularExpressions" Version="4.1.0" />
<PackageReference Include="NETStandard.Library" Version="1.6.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
<PackageReference Include="XliffTasks" Version="$(XliffTasksPackageVersion)" PrivateAssets="All" />
</ItemGroup>
</Project>

View file

@ -3,8 +3,8 @@
<PropertyGroup>
<Version>$(SdkVersion)</Version>
<TargetFrameworks>netstandard1.5;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard1.5</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netstandard2.0</TargetFrameworks>
<WarningsAsErrors>true</WarningsAsErrors>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
@ -28,11 +28,12 @@
<PackageReference Include="XliffTasks" Version="$(XliffTasksPackageVersion)" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETStandard' ">
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
<PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />

View file

@ -3,7 +3,7 @@
<PropertyGroup>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netstandard1.5</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<WarningsAsErrors>true</WarningsAsErrors>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>

View file

@ -18,7 +18,7 @@
<PackageReference Include="NETStandard.Library" Version="1.6.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETStandard' ">
<PackageReference Include="System.AppContext" Version="4.1.0" />
<PackageReference Include="System.Collections" Version="4.0.11" />
<PackageReference Include="System.IO" Version="4.1.0" />

View file

@ -4,8 +4,8 @@
// NOTE: Currently, only the NET46 build ships (with Visual Studio/desktop msbuild),
// but the netstandard1.5 adaptation here acts a proof-of-concept for cross-platform
// portability of the underlying hostfxr API and gives us build and test coverage
// on non-Windows machines.
#if NETSTANDARD1_5
// on non-Windows machines. It also ships with msbuild on Mono.
#if NETSTANDARD2_0
using System;
using System.Runtime.InteropServices;
@ -50,4 +50,4 @@ namespace Microsoft.DotNet.MSBuildSdkResolver
}
}
#endif // NETSTANDARD1_5
#endif // NETSTANDARD2_0

View file

@ -176,7 +176,7 @@ namespace Microsoft.DotNet.MSBuildSdkResolver
var environmentProvider = new EnvironmentProvider(_getEnvironmentVariable);
var dotnetExe = environmentProvider.GetCommandPath("dotnet");
#if NETSTANDARD1_5
#if NETSTANDARD2_0
if (dotnetExe != null && !Interop.RunningOnWindows)
{
// e.g. on Linux the 'dotnet' command from PATH is a symlink so we need to

View file

@ -3,8 +3,8 @@
<PropertyGroup>
<Version>$(SdkVersion)</Version>
<TargetFrameworks>netstandard1.5;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard1.5</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net46</TargetFrameworks>
<TargetFrameworks Condition="'$(OS)' != 'Windows_NT'">netstandard2.0</TargetFrameworks>
<PlatformTarget>AnyCPU</PlatformTarget>
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
<WarningsAsErrors>true</WarningsAsErrors>
@ -20,11 +20,16 @@
<PackageReference Include="Microsoft.NETCore.DotNetHostResolver" Version="$(MicrosoftNETCoreDotNetHostResolverPackageVersion)" PrivateAssets="All" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard1.5'">
<PackageReference Include="NETStandard.Library" Version="1.6.0" />
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETStandard'">
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup>
<Target Name="ResolveHostfxrCopyLocalContent" Condition="'$(TargetFramework)' == 'net46'" DependsOnTargets="ResolvePackageDependenciesForBuild" BeforeTargets="AssignTargetPaths">
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<Target Name="ResolveHostfxrCopyLocalContent" Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'" DependsOnTargets="RunResolvePackageDependencies" BeforeTargets="AssignTargetPaths">
<ItemGroup>
<Content Include="@(FileDefinitions->'%(ResolvedPath)')" Condition="'%(FileDefinitions.Path)' == 'runtimes/win-x86/native/hostfxr.dll'">
<Link>x86/hostfxr.dll</Link>

View file

@ -4,10 +4,11 @@
<PropertyGroup>
<Description>Microsoft.DotNet.TestFramework Class Library</Description>
<VersionPrefix>$(CliVersionPrefix)</VersionPrefix>
<TargetFramework>netstandard1.5</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion>
</PropertyGroup>
<ItemGroup>

View file

@ -50,7 +50,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.3.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.4.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.0.0" />
<PackageReference Include="Microsoft.NETCore.App" Version="$(MicrosoftNETCoreAppPackageVersion)" />
<PackageReference Include="System.Diagnostics.TraceSource" Version="4.3.0" />

View file

@ -22,7 +22,7 @@
<PackageReference Include="Microsoft.Deployment.WindowsInstaller" Version="1.0.0" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System.Runtime" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />

View file

@ -29,7 +29,7 @@
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<ItemGroup Condition=" '$(TargetFrameworkIdentifier)' == '.NETFramework' ">
<Reference Include="System.Core" />
</ItemGroup>

View file

@ -3,13 +3,13 @@
<PropertyGroup>
<Description>Microsoft.DotNet.Tools.Tests.Utilities Class Library</Description>
<TargetFramework>netstandard1.5</TargetFramework>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Microsoft.DotNet.Tools.Tests.Utilities</AssemblyName>
<AssemblyOriginatorKeyFile>../../tools/Key.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<AssetTargetFallback>$(AssetTargetFallback);dotnet5.4;portable-net451+win8</AssetTargetFallback>
<NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion>
<NetStandardImplicitPackageVersion>2.0.0</NetStandardImplicitPackageVersion>
</PropertyGroup>
<ItemGroup>