Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.

Commit c8bae2f

Browse files
author
Nate McMaster
committed
Simplify the tool_launcher to build for just one version of .NET Framework
1 parent e3a1939 commit c8bae2f

File tree

6 files changed

+13
-100
lines changed

6 files changed

+13
-100
lines changed

src/dotnet/OSVersionUtil.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/dotnet/ShellShim/ShellShimMaker.cs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,15 @@ namespace Microsoft.DotNet.ShellShim
1515
{
1616
public class ShellShimMaker
1717
{
18-
private const string LauncherExeNet45ResourceName = "Microsoft.DotNet.Tools.Launcher.Executable.Net45";
19-
private const string LauncherExeNet35ResourceName = "Microsoft.DotNet.Tools.Launcher.Executable.Net35";
20-
private const string LauncherConfigNet45ResourceName = "Microsoft.DotNet.Tools.Launcher.Config.Net45";
21-
private const string LauncherConfigNet35ResourceName = "Microsoft.DotNet.Tools.Launcher.Config.Net35";
18+
private const string LauncherExeResourceName = "Microsoft.DotNet.Tools.Launcher.Executable";
19+
private const string LauncherConfigResourceName = "Microsoft.DotNet.Tools.Launcher.Config";
2220

23-
private readonly string _launcherExeResourceName;
24-
private readonly string _launcherConfigResourceName;
2521
private readonly string _pathToPlaceShim;
2622

2723
public ShellShimMaker(string pathToPlaceShim)
2824
{
2925
_pathToPlaceShim =
3026
pathToPlaceShim ?? throw new ArgumentNullException(nameof(pathToPlaceShim));
31-
32-
if (OSVersionUtil.IsWindows8OrNewer())
33-
{
34-
_launcherExeResourceName = LauncherExeNet45ResourceName;
35-
_launcherConfigResourceName = LauncherConfigNet45ResourceName;
36-
}
37-
else
38-
{
39-
_launcherExeResourceName = LauncherExeNet35ResourceName;
40-
_launcherConfigResourceName = LauncherConfigNet35ResourceName;
41-
}
4227
}
4328

4429
public void CreateShim(string packageExecutablePath, string shellCommandName)
@@ -49,7 +34,7 @@ public void CreateShim(string packageExecutablePath, string shellCommandName)
4934
{
5035
CreateConfigFile(shimPath.Value + ".config", entryPoint: packageExecutablePath, runner: "dotnet");
5136
using (var shim = File.Create(shimPath.Value))
52-
using (var exe = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(_launcherExeResourceName))
37+
using (var exe = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(LauncherExeResourceName))
5338
{
5439
exe.CopyTo(shim);
5540
}
@@ -81,7 +66,7 @@ public void EnsureCommandNameUniqueness(string shellCommandName)
8166
internal void CreateConfigFile(string outputPath, string entryPoint, string runner)
8267
{
8368
XDocument config;
84-
using (var resource = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(_launcherConfigResourceName))
69+
using (var resource = typeof(ShellShimMaker).Assembly.GetManifestResourceStream(LauncherConfigResourceName))
8570
{
8671
config = XDocument.Load(resource);
8772
}

src/dotnet/dotnet.win.targets

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,16 @@
99
<ProjectReference Include="..\tool_launcher\tool_launcher.csproj"
1010
ReferenceOutputAssembly="false"
1111
SkipGetTargetFrameworkProperties="true"
12-
SetTargetFramework="TargetFramework=net45"
13-
PrivateAssets="All" />
14-
<ProjectReference Include="..\tool_launcher\tool_launcher.csproj"
15-
ReferenceOutputAssembly="false"
16-
SkipGetTargetFrameworkProperties="true"
17-
SetTargetFramework="TargetFramework=net35"
1812
PrivateAssets="All" />
1913
</ItemGroup>
2014

2115
<Target Name="EmbedDotnetLauncher" BeforeTargets="PrepareForBuild">
22-
<MSBuild Projects="..\tool_launcher\tool_launcher.csproj" Targets="GetTargetPath" Properties="TargetFramework=net45;Configuration=$(Configuration)">
23-
<Output TaskParameter="TargetOutputs" PropertyName="DotnetLauncherNet45FullPath" />
24-
</MSBuild>
25-
<MSBuild Projects="..\tool_launcher\tool_launcher.csproj" Targets="GetTargetPath" Properties="TargetFramework=net35;Configuration=$(Configuration)">
26-
<Output TaskParameter="TargetOutputs" PropertyName="DotnetLauncherNet35FullPath" />
16+
<MSBuild Projects="..\tool_launcher\tool_launcher.csproj" Targets="GetTargetPath" Properties="Configuration=$(Configuration)">
17+
<Output TaskParameter="TargetOutputs" PropertyName="DotnetLauncherFullPath" />
2718
</MSBuild>
2819
<ItemGroup>
29-
<EmbeddedResource Include="$(DotnetLauncherNet45FullPath)" LogicalName="Microsoft.DotNet.Tools.Launcher.Executable.Net45" />
30-
<EmbeddedResource Include="$(DotnetLauncherNet45FullPath).config" LogicalName="Microsoft.DotNet.Tools.Launcher.Config.Net45" />
31-
<EmbeddedResource Include="$(DotnetLauncherNet35FullPath)" LogicalName="Microsoft.DotNet.Tools.Launcher.Executable.Net35" />
32-
<EmbeddedResource Include="$(DotnetLauncherNet35FullPath).config" LogicalName="Microsoft.DotNet.Tools.Launcher.Config.Net35" />
20+
<EmbeddedResource Include="$(DotnetLauncherFullPath)" LogicalName="Microsoft.DotNet.Tools.Launcher.Executable" />
21+
<EmbeddedResource Include="$(DotnetLauncherFullPath).config" LogicalName="Microsoft.DotNet.Tools.Launcher.Config" />
3322
</ItemGroup>
3423
</Target>
3524

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Generated by the .NET Core Command Line.
33
-->
44
<configuration>
55
<startup>
6+
<supportedRuntime version="v2.0.50727" />
67
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
78
</startup>
89
<appSettings>

src/tool_launcher/app.net35.config

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/tool_launcher/tool_launcher.csproj

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<!-- Targets .NET Framework 3.5 because .NET Framework 4 is not bundled in Windows 7. -->
4-
<TargetFrameworks>net45;net35</TargetFrameworks>
3+
<!-- Targets .NET Framework 3.5 because .NET Framework 4.5 is not bundled in Windows 7. -->
4+
<TargetFramework>net35</TargetFramework>
55
<PlatformTarget>AnyCPU</PlatformTarget>
66
<OutputType>exe</OutputType>
77
<IsPackable>false</IsPackable>
@@ -10,26 +10,18 @@
1010
<Description>
1111
A simple Windows-only shim for launching new processes.
1212
</Description>
13-
<AppConfig>app.$(TargetFramework).config</AppConfig>
14-
<!-- In other words, a workaround for issues with cmd.exe. -->
1513
</PropertyGroup>
1614

1715
<!-- This project must not have any package references. It must be a standalone .exe file -->
18-
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
19-
<Reference Include="System" />
20-
<Reference Include="System.Configuration" />
21-
<Reference Include="System.Linq" />
22-
</ItemGroup>
23-
24-
<ItemGroup Condition="'$(TargetFramework)' == 'net35'">
16+
<ItemGroup>
2517
<Reference Include="System" />
2618
<Reference Include="System.Configuration" />
2719
<Reference Include="System.Core" />
2820
</ItemGroup>
2921

3022
<!-- Workaround https://github.com/Microsoft/msbuild/issues/1333 -->
3123
<PropertyGroup>
32-
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
24+
<FrameworkPathOverride>$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
3325
</PropertyGroup>
3426

3527
<ItemGroup>

0 commit comments

Comments
 (0)