* Feat. msi

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* remove ununsed file

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-04-02 18:10:09 +08:00
committed by GitHub
parent 2b20714f50
commit db6bf547a9
22 changed files with 1100 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<!--
Use supportedRuntime tags to explicitly specify the version(s) of the .NET Framework runtime that
the custom action should run on. If no versions are specified, the chosen version of the runtime
will be the "best" match to what WixToolset.Dtf.CustomAction.dll was built against.
WARNING: leaving the version unspecified is dangerous as it introduces a risk of compatibility
problems with future versions of the .NET Framework runtime. It is highly recommended that you specify
only the version(s) of the .NET Framework runtime that you have tested against.
For more information https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/startup/startup-element
-->
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Diagnostics;
using System.Runtime.InteropServices;
using WixToolset.Dtf.WindowsInstaller;
namespace CustomActions
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomActionHello(Session session)
{
try
{
session.Log("================= Example CustomAction Hello");
return ActionResult.Success;
}
catch (Exception e)
{
session.Log("An error occurred: " + e.Message);
return ActionResult.Failure;
}
}
[CustomAction]
public static ActionResult RunCommandAsSystem(Session session)
{
try
{
ProcessStartInfo psi = new ProcessStartInfo
{
FileName = "cmd.exe",
Arguments = "/c " + session["CMD"],
UseShellExecute = false,
WindowStyle = ProcessWindowStyle.Hidden,
Verb = "runas"
};
using (Process process = Process.Start(psi))
{
process.WaitForExit();
}
return ActionResult.Success;
}
catch (Exception e)
{
session.Log("An error occurred: " + e.Message);
return ActionResult.Failure;
}
}
}
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<Configurations>Release</Configurations>
</PropertyGroup>
<ItemGroup>
<Content Include="CustomAction.config" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="WixToolset.Dtf.CustomAction" Version="4.0.5" />
<PackageReference Include="WixToolset.Dtf.WindowsInstaller" Version="4.0.5" />
</ItemGroup>
</Project>