Skip to content

Commit afcc0fd

Browse files
committed
backup
Co-authored-by: frg2089<[email protected]>
1 parent 891f193 commit afcc0fd

8 files changed

+1021
-0
lines changed

.editorconfig

+364
Large diffs are not rendered by default.

.gitignore

+480
Large diffs are not rendered by default.

MsixInstaller.csproj

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>WinExe</OutputType>
5+
<TargetFramework>net48</TargetFramework>
6+
<LangVersion>latest</LangVersion>
7+
<Nullable>enable</Nullable>
8+
<UseWPF>true</UseWPF>
9+
<ApplicationManifest>app.manifest</ApplicationManifest>
10+
<OutDir Condition=" '$(Configuration)' == 'Release' ">$(MSBuildThisFileDirectory)..\build\windows\x64\runner\Release</OutDir>
11+
<NeutralLanguage>zh-Hans</NeutralLanguage>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<EmbeddedResource Include="pixeval.msix" Link="pixeval.msix" LogicalName="msix" />
16+
</ItemGroup>
17+
18+
</Project>

MsixInstaller.sln

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsixInstaller", "MsixInstaller.csproj", "{7151B072-125C-451D-B07F-7C87F6C5AD73}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(SolutionProperties) = preSolution
14+
HideSolutionNode = FALSE
15+
EndGlobalSection
16+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
17+
{7151B072-125C-451D-B07F-7C87F6C5AD73}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
18+
{7151B072-125C-451D-B07F-7C87F6C5AD73}.Debug|Any CPU.Build.0 = Debug|Any CPU
19+
{7151B072-125C-451D-B07F-7C87F6C5AD73}.Release|Any CPU.ActiveCfg = Release|Any CPU
20+
{7151B072-125C-451D-B07F-7C87F6C5AD73}.Release|Any CPU.Build.0 = Release|Any CPU
21+
EndGlobalSection
22+
EndGlobal

Program.cs

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System.Diagnostics;
2+
using System.IO;
3+
using System.Linq;
4+
using System.Security.Cryptography.X509Certificates;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
8+
string path = $"{Path.GetTempFileName()}.msix";
9+
using (Stream stream = typeof(Program).Assembly.GetManifestResourceStream("msix"))
10+
using (FileStream fileStream = File.Create(path))
11+
stream.CopyTo(fileStream);
12+
13+
try
14+
{
15+
X509Certificate2 x509Certificate = new(X509Certificate.CreateFromSignedFile(path));
16+
X509Store store = new(StoreName.TrustedPeople, StoreLocation.LocalMachine);
17+
store.Open(OpenFlags.ReadWrite);
18+
if (store.Certificates.Find(X509FindType.FindBySubjectDistinguishedName, x509Certificate.Subject, true) is { Count: 0 })
19+
{
20+
MessageBoxResult messageBoxResult = MessageBox.Show(
21+
$"""
22+
您是否要添加以下证书到计算机受信任人存储区?
23+
24+
{x509Certificate.Subject}
25+
""",
26+
"提示",
27+
MessageBoxButton.OKCancel,
28+
MessageBoxImage.Question);
29+
30+
if (messageBoxResult is not MessageBoxResult.OK)
31+
return;
32+
33+
store.Add(x509Certificate);
34+
}
35+
Process.Start(path);
36+
Task.WaitAll(Process.GetProcesses()
37+
.Where(i => i.ProcessName is "AppInstaller")
38+
.Select(i => Task.Run(i.WaitForExit))
39+
.ToArray());
40+
}
41+
finally
42+
{
43+
File.Delete(path);
44+
}

app.manifest

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<!-- UAC 清单选项
8+
如果想要更改 Windows 用户帐户控制级别,请使用
9+
以下节点之一替换 requestedExecutionLevel 节点。
10+
11+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
12+
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13+
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14+
15+
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
16+
如果你的应用程序需要此虚拟化来实现向后兼容性,则移除此
17+
元素。
18+
-->
19+
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
20+
</requestedPrivileges>
21+
</security>
22+
</trustInfo>
23+
24+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
25+
<application>
26+
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
27+
Windows 版本的列表。取消评论适当的元素,
28+
Windows 将自动选择最兼容的环境。 -->
29+
30+
<!-- Windows Vista -->
31+
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
32+
33+
<!-- Windows 7 -->
34+
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
35+
36+
<!-- Windows 8 -->
37+
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38+
39+
<!-- Windows 8.1 -->
40+
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
41+
42+
<!-- Windows 10 -->
43+
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
44+
45+
</application>
46+
</compatibility>
47+
48+
<!-- 指示该应用程序可感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
49+
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
50+
选择加入。选择加入此设置的 Windows 窗体应用程序(面向 .NET Framework 4.6)还应
51+
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。
52+
53+
将应用程序设为感知长路径。请参阅 https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation -->
54+
<!--
55+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
56+
<windowsSettings>
57+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
58+
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
59+
</windowsSettings>
60+
</application>
61+
-->
62+
63+
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
64+
65+
<dependency>
66+
<dependentAssembly>
67+
<assemblyIdentity
68+
type="win32"
69+
name="Microsoft.Windows.Common-Controls"
70+
version="6.0.0.0"
71+
processorArchitecture="*"
72+
publicKeyToken="6595b64144ccf1df"
73+
language="*"
74+
/>
75+
</dependentAssembly>
76+
</dependency>
77+
78+
79+
</assembly>

global.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"sdk": {
3+
"rollForward": "major",
4+
"version": "7.0.306"
5+
}
6+
}

nuget.config

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<packageSources>
4+
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
5+
<clear />
6+
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
7+
</packageSources>
8+
</configuration>

0 commit comments

Comments
 (0)