Skip to content

Commit

Permalink
remove all guard with ResourceUpdater.IsSupportedOS()
Browse files Browse the repository at this point in the history
ResourceUpdater.IsSupportedOS() will always return true since dotnet/runtime#89303
  • Loading branch information
anatawa12 committed Aug 8, 2023
1 parent ca80028 commit 90f83e8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 35 deletions.
27 changes: 6 additions & 21 deletions src/Cli/dotnet/ShellShim/AppHostShimMaker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.DotNet.Tools;
using Microsoft.Extensions.EnvironmentAbstractions;
using Microsoft.NET.HostModel;
using Microsoft.NET.HostModel.AppHost;

namespace Microsoft.DotNet.ShellShim
Expand Down Expand Up @@ -41,26 +40,12 @@ public void CreateApphostShellShim(FilePath entryPoint, FilePath shimPath)
var appBinaryFilePath = Path.GetRelativePath(Path.GetDirectoryName(appHostDestinationFilePath), entryPointFullPath);


if (ResourceUpdater.IsSupportedOS())
{
var windowsGraphicalUserInterfaceBit = PEUtils.GetWindowsGraphicalUserInterfaceBit(entryPointFullPath);
HostWriter.CreateAppHost(appHostSourceFilePath: appHostSourcePath,
appHostDestinationFilePath: appHostDestinationFilePath,
appBinaryFilePath: appBinaryFilePath,
windowsGraphicalUserInterface: (windowsGraphicalUserInterfaceBit == WindowsGUISubsystem),
assemblyToCopyResourcesFrom: entryPointFullPath);
}
else
{
// by passing null to assemblyToCopyResourcesFrom, it will skip copying resources,
// which is only supported on Windows
HostWriter.CreateAppHost(appHostSourceFilePath: appHostSourcePath,
appHostDestinationFilePath: appHostDestinationFilePath,
appBinaryFilePath: appBinaryFilePath,
windowsGraphicalUserInterface: false,
assemblyToCopyResourcesFrom: null,
enableMacOSCodeSign: OperatingSystem.IsMacOS());
}
var windowsGraphicalUserInterfaceBit = PEUtils.GetWindowsGraphicalUserInterfaceBit(entryPointFullPath);
HostWriter.CreateAppHost(appHostSourceFilePath: appHostSourcePath,
appHostDestinationFilePath: appHostDestinationFilePath,
appBinaryFilePath: appBinaryFilePath,
windowsGraphicalUserInterface: (windowsGraphicalUserInterfaceBit == WindowsGUISubsystem),
assemblyToCopyResourcesFrom: entryPointFullPath);

_filePermissionSetter.SetUserExecutionPermission(appHostDestinationFilePath);
}
Expand Down
13 changes: 1 addition & 12 deletions src/Tasks/Microsoft.NET.Build.Tasks/CreateAppHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,8 @@ protected override void ExecuteCore()
var isGUI = WindowsGraphicalUserInterface;
var resourcesAssembly = IntermediateAssembly;

if (!ResourceUpdater.IsSupportedOS())
{
if (isGUI)
{
Log.LogWarning(Strings.AppHostCustomizationRequiresWindowsHostWarning);
}

isGUI = false;
resourcesAssembly = null;
}

int attempts = 0;

while (true)
{
try
Expand Down
3 changes: 1 addition & 2 deletions src/Tasks/Microsoft.NET.Build.Tasks/GenerateShims.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Microsoft.NET.HostModel;
using Microsoft.NET.HostModel.AppHost;
using NuGet.Versioning;

Expand Down Expand Up @@ -108,7 +107,7 @@ protected override void ExecuteCore()
try
{
var windowsGraphicalUserInterface = runtimeIdentifier.StartsWith("win") && "WinExe".Equals(OutputType, StringComparison.OrdinalIgnoreCase);
if (ResourceUpdater.IsSupportedOS() && runtimeIdentifier.StartsWith("win"))
if (runtimeIdentifier.StartsWith("win"))
{
HostWriter.CreateAppHost(appHostSourceFilePath: resolvedApphostAssetPath,
appHostDestinationFilePath: appHostDestinationFilePath,
Expand Down

0 comments on commit 90f83e8

Please sign in to comment.