提交 f3ea23f2 编写于 作者: A Aigio Liu

🔥 Remove Com Ref

上级 4d4dbfb2
......@@ -85,7 +85,7 @@ interface IDotNetPublishCommand : ICommand
DirTryDelete(rootPublishDir);
// 发布主体
StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
// 验证 Avalonia.Base.dll 版本号必须为 11+
var avaloniaBaseDllPath = Path.Combine(publishDir, "Avalonia.Base.dll");
......@@ -804,7 +804,7 @@ publish -c {0} -p:OutputType={1} -p:PublishDir=bin\{0}\Publish\win-any -p:Publis
var argument = string.Join(' ', psi.ArgumentList);
Console.WriteLine(argument);
StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
var publishDir = Path.Combine(projRootPath, arg.PublishDir);
CopyDirectory(publishDir, destinationDir, true);
......
......@@ -15,23 +15,11 @@ static partial class DotNetCLIHelper
IOPath.DirTryDelete(objPath);
}
public static void StartProcessAndWaitForExit(ProcessStartInfo psi)
{
var process = Process.Start(psi);
process.ThrowIsNull();
process.WaitForExit();
var exitCode = process.ExitCode;
if (exitCode != default)
{
throw new ArgumentOutOfRangeException(nameof(exitCode), exitCode, null);
}
}
public static void StartProcessAndWaitForExit(string workingDirectory, string? arguments = null)
{
var psi = GetProcessStartInfo(workingDirectory);
if (arguments != null) psi.Arguments = arguments;
StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
}
public static ProcessStartInfo GetProcessStartInfo(string workingDirectory)
......
......@@ -54,7 +54,7 @@ createconfig /cf "{xmlPath}" /dq lang-en-US /o /pv 10.0.0
""",
WorkingDirectory = rootPublicPath,
};
DotNetCLIHelper.StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
var prPath = $@"{ProjectUtils.ProjPath}\res\windows\makepri";
CopyDirectory(prPath, rootPublicPath, true);
psi = new ProcessStartInfo
......@@ -67,7 +67,7 @@ new /cf "{xmlPath}" /pr "{prPath}"
""",
WorkingDirectory = rootPublicPath,
};
DotNetCLIHelper.StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
IOPath.FileIfExistsItDelete(xmlPath);
}
......@@ -119,7 +119,7 @@ $"""
pack /v /h SHA256 /d "{rootPublicPath}" /p "{msixPath}"
""",
};
DotNetCLIHelper.StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
}
/// <summary>
......@@ -299,7 +299,7 @@ $"""
sign /a /fd SHA256 /f "{pfxFilePath}" /p "{pwdS}" /tr {timestamp_url} /td SHA256 {fileName}
""",
};
DotNetCLIHelper.StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
}
}
......
......@@ -56,14 +56,18 @@ static class ObfuscarHelper
{
WriteConfig(dirPath);
var psi = new ProcessStartInfo
var psi = DotNetCLIHelper.GetProcessStartInfo(AppContext.BaseDirectory);
psi.Arguments = "tool install --global Obfuscar.GlobalTool";
ProcessHelper.StartAndWaitForExit(psi);
psi = new ProcessStartInfo
{
FileName = "obfuscar.console.exe",
UseShellExecute = false,
Arguments = configFileName,
WorkingDirectory = dirPath,
};
DotNetCLIHelper.StartProcessAndWaitForExit(psi);
ProcessHelper.StartAndWaitForExit(psi);
var oldFilePath = Path.Combine(dirPath, "Steam++.exe");
var newFilePath = Path.Combine(dirPath, "Obfuscar", "Steam++.exe");
......
namespace BD.WTTS.Client.Tools.Publish.Helpers;
static partial class ProcessHelper
{
public static void StartAndWaitForExit(ProcessStartInfo psi, bool ignoreExitCode = false)
{
var process = Process.Start(psi);
process.ThrowIsNull();
process.WaitForExit();
if (ignoreExitCode) return;
var exitCode = process.ExitCode;
if (exitCode != default)
{
throw new ArgumentOutOfRangeException(nameof(exitCode), exitCode, null);
}
}
}
......@@ -142,7 +142,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.EventLog" />
<PackageReference Include="Microsoft.Win32.SystemEvents" />
<PackageReference Include="Vanara.PInvoke.PowrProf" />
<COMReference Include="IWshRuntimeLibrary">
<!--<COMReference Include="IWshRuntimeLibrary">
<WrapperTool>tlbimp</WrapperTool>
<VersionMinor>0</VersionMinor>
<VersionMajor>1</VersionMajor>
......@@ -150,7 +150,10 @@
<Lcid>0</Lcid>
<Isolated>false</Isolated>
<EmbedInteropTypes>true</EmbedInteropTypes>
</COMReference>
</COMReference>-->
<Reference Include="Interop.IWshRuntimeLibrary">
<HintPath>..\..\ref\Interop.IWshRuntimeLibrary.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'macos' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' OR $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == ''">
......
[assembly: InternalsVisibleTo("BD.WTTS.UnitTest")]
[assembly: InternalsVisibleTo("Steam++")]
[assembly: InternalsVisibleTo("Steam++.Designer")]
......@@ -9,23 +9,35 @@ partial class WindowsPlatformServiceImpl
/// <summary>
/// 创建一个快捷方式
/// </summary>
/// <param name="pathLink"></param>
/// <param name="targetPath"></param>
/// <param name="arguments"></param>
/// <param name="workingDirectory"></param>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void CreateShortcut(
string pathLink,
string targetPath,
string? arguments = null,
string? description = null,
string? hotkey = null,
string? iconLocation = null,
string? workingDirectory = null)
{
WshShell shell = new();
IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(pathLink);
var shortcut = (IWshShortcut)shell.CreateShortcut(pathLink);
shortcut.TargetPath = targetPath;
if (!string.IsNullOrEmpty(description))
shortcut.Description = description;
if (!string.IsNullOrEmpty(arguments))
shortcut.Arguments = arguments;
if (!string.IsNullOrEmpty(hotkey))
shortcut.Hotkey = hotkey;
if (!string.IsNullOrEmpty(iconLocation))
shortcut.IconLocation = iconLocation;
if (!string.IsNullOrEmpty(workingDirectory))
shortcut.WorkingDirectory = workingDirectory;
shortcut.Save();
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册