Simplify the tool_launcher to build for just one version of .NET Framework
This commit is contained in:
parent
e3a19395fb
commit
c8bae2ffda
6 changed files with 13 additions and 100 deletions
|
@ -1,36 +0,0 @@
|
||||||
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using Microsoft.DotNet.PlatformAbstractions;
|
|
||||||
|
|
||||||
namespace Microsoft.DotNet
|
|
||||||
{
|
|
||||||
class OSVersionUtil
|
|
||||||
{
|
|
||||||
public static bool IsWindows8OrNewer()
|
|
||||||
{
|
|
||||||
if (RuntimeEnvironment.OperatingSystemPlatform != Platform.Windows)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Version.TryParse(RuntimeEnvironment.OperatingSystemVersion, out var winVersion))
|
|
||||||
{
|
|
||||||
// All current versions of Windows have a valid System.Version value for OperatingSystemVersion.
|
|
||||||
// If parsing fails, let's assume Windows is newer than Win 8.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Windows 7 = "6.1"
|
|
||||||
// Windows 8 = "6.2"
|
|
||||||
// Windows 8.1 = "6.3"
|
|
||||||
if (winVersion.Major > 6)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return winVersion.Minor >= 2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -15,30 +15,15 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
{
|
{
|
||||||
public class ShellShimMaker
|
public class ShellShimMaker
|
||||||
{
|
{
|
||||||
private const string LauncherExeNet45ResourceName = "Microsoft.DotNet.Tools.Launcher.Executable.Net45";
|
private const string LauncherExeResourceName = "Microsoft.DotNet.Tools.Launcher.Executable";
|
||||||
private const string LauncherExeNet35ResourceName = "Microsoft.DotNet.Tools.Launcher.Executable.Net35";
|
private const string LauncherConfigResourceName = "Microsoft.DotNet.Tools.Launcher.Config";
|
||||||
private const string LauncherConfigNet45ResourceName = "Microsoft.DotNet.Tools.Launcher.Config.Net45";
|
|
||||||
private const string LauncherConfigNet35ResourceName = "Microsoft.DotNet.Tools.Launcher.Config.Net35";
|
|
||||||
|
|
||||||
private readonly string _launcherExeResourceName;
|
|
||||||
private readonly string _launcherConfigResourceName;
|
|
||||||
private readonly string _pathToPlaceShim;
|
private readonly string _pathToPlaceShim;
|
||||||
|
|
||||||
public ShellShimMaker(string pathToPlaceShim)
|
public ShellShimMaker(string pathToPlaceShim)
|
||||||
{
|
{
|
||||||
_pathToPlaceShim =
|
_pathToPlaceShim =
|
||||||
pathToPlaceShim ?? throw new ArgumentNullException(nameof(pathToPlaceShim));
|
pathToPlaceShim ?? throw new ArgumentNullException(nameof(pathToPlaceShim));
|
||||||
|
|
||||||
if (OSVersionUtil.IsWindows8OrNewer())
|
|
||||||
{
|
|
||||||
_launcherExeResourceName = LauncherExeNet45ResourceName;
|
|
||||||
_launcherConfigResourceName = LauncherConfigNet45ResourceName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_launcherExeResourceName = LauncherExeNet35ResourceName;
|
|
||||||
_launcherConfigResourceName = LauncherConfigNet35ResourceName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CreateShim(string packageExecutablePath, string shellCommandName)
|
public void CreateShim(string packageExecutablePath, string shellCommandName)
|
||||||
|
@ -49,7 +34,7 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
{
|
{
|
||||||
CreateConfigFile(shimPath.Value + ".config", entryPoint: packageExecutablePath, runner: "dotnet");
|
CreateConfigFile(shimPath.Value + ".config", entryPoint: packageExecutablePath, runner: "dotnet");
|
||||||
using (var shim = File.Create(shimPath.Value))
|
using (var shim = File.Create(shimPath.Value))
|
||||||
using (var exe = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(_launcherExeResourceName))
|
using (var exe = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(LauncherExeResourceName))
|
||||||
{
|
{
|
||||||
exe.CopyTo(shim);
|
exe.CopyTo(shim);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +66,7 @@ namespace Microsoft.DotNet.ShellShim
|
||||||
internal void CreateConfigFile(string outputPath, string entryPoint, string runner)
|
internal void CreateConfigFile(string outputPath, string entryPoint, string runner)
|
||||||
{
|
{
|
||||||
XDocument config;
|
XDocument config;
|
||||||
using (var resource = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(_launcherConfigResourceName))
|
using (var resource = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(LauncherConfigResourceName))
|
||||||
{
|
{
|
||||||
config = XDocument.Load(resource);
|
config = XDocument.Load(resource);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,27 +9,16 @@
|
||||||
<ProjectReference Include="..\tool_launcher\tool_launcher.csproj"
|
<ProjectReference Include="..\tool_launcher\tool_launcher.csproj"
|
||||||
ReferenceOutputAssembly="false"
|
ReferenceOutputAssembly="false"
|
||||||
SkipGetTargetFrameworkProperties="true"
|
SkipGetTargetFrameworkProperties="true"
|
||||||
SetTargetFramework="TargetFramework=net45"
|
|
||||||
PrivateAssets="All" />
|
|
||||||
<ProjectReference Include="..\tool_launcher\tool_launcher.csproj"
|
|
||||||
ReferenceOutputAssembly="false"
|
|
||||||
SkipGetTargetFrameworkProperties="true"
|
|
||||||
SetTargetFramework="TargetFramework=net35"
|
|
||||||
PrivateAssets="All" />
|
PrivateAssets="All" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Target Name="EmbedDotnetLauncher" BeforeTargets="PrepareForBuild">
|
<Target Name="EmbedDotnetLauncher" BeforeTargets="PrepareForBuild">
|
||||||
<MSBuild Projects="..\tool_launcher\tool_launcher.csproj" Targets="GetTargetPath" Properties="TargetFramework=net45;Configuration=$(Configuration)">
|
<MSBuild Projects="..\tool_launcher\tool_launcher.csproj" Targets="GetTargetPath" Properties="Configuration=$(Configuration)">
|
||||||
<Output TaskParameter="TargetOutputs" PropertyName="DotnetLauncherNet45FullPath" />
|
<Output TaskParameter="TargetOutputs" PropertyName="DotnetLauncherFullPath" />
|
||||||
</MSBuild>
|
|
||||||
<MSBuild Projects="..\tool_launcher\tool_launcher.csproj" Targets="GetTargetPath" Properties="TargetFramework=net35;Configuration=$(Configuration)">
|
|
||||||
<Output TaskParameter="TargetOutputs" PropertyName="DotnetLauncherNet35FullPath" />
|
|
||||||
</MSBuild>
|
</MSBuild>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="$(DotnetLauncherNet45FullPath)" LogicalName="Microsoft.DotNet.Tools.Launcher.Executable.Net45" />
|
<EmbeddedResource Include="$(DotnetLauncherFullPath)" LogicalName="Microsoft.DotNet.Tools.Launcher.Executable" />
|
||||||
<EmbeddedResource Include="$(DotnetLauncherNet45FullPath).config" LogicalName="Microsoft.DotNet.Tools.Launcher.Config.Net45" />
|
<EmbeddedResource Include="$(DotnetLauncherFullPath).config" LogicalName="Microsoft.DotNet.Tools.Launcher.Config" />
|
||||||
<EmbeddedResource Include="$(DotnetLauncherNet35FullPath)" LogicalName="Microsoft.DotNet.Tools.Launcher.Executable.Net35" />
|
|
||||||
<EmbeddedResource Include="$(DotnetLauncherNet35FullPath).config" LogicalName="Microsoft.DotNet.Tools.Launcher.Config.Net35" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ Generated by the .NET Core Command Line.
|
||||||
-->
|
-->
|
||||||
<configuration>
|
<configuration>
|
||||||
<startup>
|
<startup>
|
||||||
|
<supportedRuntime version="v2.0.50727" />
|
||||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||||
</startup>
|
</startup>
|
||||||
<appSettings>
|
<appSettings>
|
|
@ -1,18 +0,0 @@
|
||||||
<!--
|
|
||||||
Generated by the .NET Core Command Line.
|
|
||||||
-->
|
|
||||||
<configuration>
|
|
||||||
<startup>
|
|
||||||
<supportedRuntime version="v2.0.50727" />
|
|
||||||
</startup>
|
|
||||||
<appSettings>
|
|
||||||
<!--
|
|
||||||
To use this launcher, this value must be set. It is a file path or name of the new process being launched.
|
|
||||||
<add key="entryPoint" value="%entrypoint%" />
|
|
||||||
|
|
||||||
This value may also be set. It is an path to another executable used to launch the entry point.
|
|
||||||
It is treated as single argument.
|
|
||||||
<add key="runner" value="%runner%" />
|
|
||||||
-->
|
|
||||||
</appSettings>
|
|
||||||
</configuration>
|
|
|
@ -1,7 +1,7 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Targets .NET Framework 3.5 because .NET Framework 4 is not bundled in Windows 7. -->
|
<!-- Targets .NET Framework 3.5 because .NET Framework 4.5 is not bundled in Windows 7. -->
|
||||||
<TargetFrameworks>net45;net35</TargetFrameworks>
|
<TargetFramework>net35</TargetFramework>
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
<OutputType>exe</OutputType>
|
<OutputType>exe</OutputType>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
|
@ -10,18 +10,10 @@
|
||||||
<Description>
|
<Description>
|
||||||
A simple Windows-only shim for launching new processes.
|
A simple Windows-only shim for launching new processes.
|
||||||
</Description>
|
</Description>
|
||||||
<AppConfig>app.$(TargetFramework).config</AppConfig>
|
|
||||||
<!-- In other words, a workaround for issues with cmd.exe. -->
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<!-- This project must not have any package references. It must be a standalone .exe file -->
|
<!-- This project must not have any package references. It must be a standalone .exe file -->
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
|
||||||
<Reference Include="System.Configuration" />
|
|
||||||
<Reference Include="System.Linq" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
|
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Configuration" />
|
<Reference Include="System.Configuration" />
|
||||||
<Reference Include="System.Core" />
|
<Reference Include="System.Core" />
|
||||||
|
@ -29,7 +21,7 @@
|
||||||
|
|
||||||
<!-- Workaround https://github.com/Microsoft/msbuild/issues/1333 -->
|
<!-- Workaround https://github.com/Microsoft/msbuild/issues/1333 -->
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
|
<FrameworkPathOverride>$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
Loading…
Add table
Reference in a new issue