Skip to content

Commit 419ec41

Browse files
authored
Merge pull request #1 from dotnet-campus/t/lindexi/CustomWpf
自定义的私有发布版本
2 parents 14a1e0e + b47e528 commit 419ec41

File tree

21 files changed

+432
-20
lines changed

21 files changed

+432
-20
lines changed

.github/workflows/Build.yml

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,42 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v1
12-
# - name: Install Nuget
13-
# uses: nuget/setup-nuget@v1
14-
# with:
15-
# nuget-version: '5.x'
16-
- name: Build
17-
run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86
18-
- name: Push
19-
uses: actions/upload-artifact@v1
12+
- name: Setup .NET
13+
uses: actions/setup-dotnet@v1
2014
with:
21-
name: WPF_Debug
22-
path: ./artifacts/packages/Debug/NonShipping
15+
dotnet-version: |
16+
3.1.x
17+
5.0.x
18+
6.0.101
19+
- name: Build WPF
20+
run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86
21+
- name: Build CustomWPF
22+
run: dotnet build CustomWpf
23+
# - name: Push
24+
# uses: actions/upload-artifact@v1
25+
# with:
26+
# name: WPF_Debug
27+
# path: ./artifacts/packages/Debug/NonShipping
2328

2429
BuildRelease:
2530

2631
runs-on: windows-latest
2732

2833
steps:
2934
- uses: actions/checkout@v1
30-
# - name: Install Nuget
31-
# uses: nuget/setup-nuget@v1
32-
# with:
33-
# nuget-version: '5.x'
34-
- name: Build
35-
run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86
36-
- name: Push
37-
uses: actions/upload-artifact@v1
35+
- name: Setup .NET
36+
uses: actions/setup-dotnet@v1
3837
with:
39-
name: WPF_Release
40-
path: ./artifacts/packages/Release/NonShipping
38+
dotnet-version: |
39+
3.1.x
40+
5.0.x
41+
6.0.101
42+
- name: Build WPF
43+
run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86
44+
- name: Build CustomWPF
45+
run: dotnet build CustomWpf -c Release
46+
# - name: Push
47+
# uses: actions/upload-artifact@v1
48+
# with:
49+
# name: WPF_Release
50+
# path: ./artifacts/packages/Release/NonShipping
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish Custom WPF
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
8+
jobs:
9+
# BuildDebug:
10+
11+
# runs-on: windows-latest
12+
13+
# steps:
14+
# - uses: actions/checkout@v1
15+
# # - name: Install Nuget
16+
# # uses: nuget/setup-nuget@v1
17+
# # with:
18+
# # nuget-version: '5.x'
19+
# - name: Build
20+
# run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86
21+
# - name: Push
22+
# uses: actions/upload-artifact@v1
23+
# with:
24+
# name: WPF_Debug
25+
# path: ./artifacts/packages/Debug/NonShipping
26+
27+
Build:
28+
29+
runs-on: windows-latest
30+
31+
steps:
32+
- uses: actions/checkout@v1
33+
- name: Setup .NET
34+
uses: actions/setup-dotnet@v1
35+
with:
36+
dotnet-version: |
37+
3.1.x
38+
5.0.x
39+
6.0.101
40+
- name: Install Tools
41+
run: dotnet tool install -g dotnetCampus.TagToVersion --add-source https://api.nuget.org/v3/index.json
42+
- name: Set Package TagToVersion
43+
run: dotnet tagtoversion -t ${{ github.ref }} -f CustomWpf\build\Version.props
44+
- name: Build WPF
45+
run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86
46+
- name: Pack NuGet
47+
run: dotnet pack CustomWpf -c release
48+
49+
- name: Install Nuget
50+
uses: nuget/setup-nuget@v1
51+
with:
52+
nuget-version: '5.x'
53+
- name: Add private GitHub registry to NuGet
54+
run: |
55+
nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }}
56+
- name: Push NuGet Package
57+
run: |
58+
nuget push .\CustomWpf\bin\Release\*.nupkg -Source github -SkipDuplicate
59+
nuget push .\CustomWpf\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }}
60+
61+
# - name: Push
62+
# uses: actions/upload-artifact@v1
63+
# with:
64+
# name: WPF_Release
65+
# path: ./artifacts/packages/Release/NonShipping

CustomWpf/CustomWpf.sln

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.32014.148
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.WPF", "Lib\dotnetCampus.CustomWpf.Lib\dotnetCampus.WPF.csproj", "{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{FE032A91-A790-4274-A194-02E161D1F14B}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packaging", "Packaging", "{27886E90-E328-4AE9-86DA-1F596554D26B}"
11+
EndProject
12+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.WPF.NuGet", "Packaging\dotnetCampus.WPF.NuGet\dotnetCampus.WPF.NuGet.csproj", "{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}"
13+
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.WPF.Resource", "Lib\dotnetCampus.CustomWpf.Resource\dotnetCampus.WPF.Resource.csproj", "{D73CB485-6290-4E37-B441-8068E60CBF7E}"
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{315B416C-6CDA-4CD5-9666-69C8272CD80E}"
17+
ProjectSection(SolutionItems) = preProject
18+
build\Version.props = build\Version.props
19+
EndProjectSection
20+
EndProject
21+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.WPF.Dependencies", "Lib\dotnetCampus.CustomWpf.Dependencies\dotnetCampus.WPF.Dependencies.csproj", "{39E01A9E-C352-4B7E-96CA-612A07937470}"
22+
EndProject
23+
Global
24+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
25+
Debug|Any CPU = Debug|Any CPU
26+
Release|Any CPU = Release|Any CPU
27+
EndGlobalSection
28+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
29+
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30+
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
31+
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34+
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
35+
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
36+
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Release|Any CPU.Build.0 = Release|Any CPU
37+
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
40+
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Release|Any CPU.Build.0 = Release|Any CPU
41+
{39E01A9E-C352-4B7E-96CA-612A07937470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42+
{39E01A9E-C352-4B7E-96CA-612A07937470}.Debug|Any CPU.Build.0 = Debug|Any CPU
43+
{39E01A9E-C352-4B7E-96CA-612A07937470}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{39E01A9E-C352-4B7E-96CA-612A07937470}.Release|Any CPU.Build.0 = Release|Any CPU
45+
EndGlobalSection
46+
GlobalSection(SolutionProperties) = preSolution
47+
HideSolutionNode = FALSE
48+
EndGlobalSection
49+
GlobalSection(NestedProjects) = preSolution
50+
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C} = {FE032A91-A790-4274-A194-02E161D1F14B}
51+
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F} = {27886E90-E328-4AE9-86DA-1F596554D26B}
52+
{D73CB485-6290-4E37-B441-8068E60CBF7E} = {FE032A91-A790-4274-A194-02E161D1F14B}
53+
{39E01A9E-C352-4B7E-96CA-612A07937470} = {FE032A91-A790-4274-A194-02E161D1F14B}
54+
EndGlobalSection
55+
GlobalSection(ExtensibilityGlobals) = postSolution
56+
SolutionGuid = {C25E6016-F278-457B-87D6-39EC0E0A6849}
57+
EndGlobalSection
58+
EndGlobal

CustomWpf/Directory.Build.props

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<Project>
2+
<Import Project="build\Version.props" />
3+
<PropertyGroup>
4+
<LangVersion>latest</LangVersion>
5+
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)</PackageOutputPath>
6+
<Company>dotnet campus(.NET 职业技术学院)</Company>
7+
8+
<Authors>dotnet-campus</Authors>
9+
<RepositoryUrl>https://github.com/dotnet-campus/dotnetCampus.Ipc</RepositoryUrl>
10+
<PackageProjectUrl>https://github.com/dotnet-campus/dotnetCampus.Ipc</PackageProjectUrl>
11+
<Description>包含定制的 WPF 版本</Description>
12+
13+
<RepositoryType>git</RepositoryType>
14+
<Copyright>Copyright © 2020-2022 dotnet campus, All Rights Reserved.</Copyright>
15+
</PropertyGroup>
16+
17+
18+
</Project>

CustomWpf/Directory.Build.targets

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
3+
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project>
2+
<Target Name="CustomWpfResolveReferences"
3+
BeforeTargets="ResolveReferences">
4+
<PropertyGroup>
5+
<CustomWpfRuntimeIdentifier Condition="'$(CustomWpfRuntimeIdentifier)' == ''">$(RuntimeIdentifier)</CustomWpfRuntimeIdentifier>
6+
<CustomWpfRuntimeIdentifier Condition="'$(CustomWpfRuntimeIdentifier)' == ''">win-x86</CustomWpfRuntimeIdentifier>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<ReferenceCopyLocalPaths Include="$(CustomWpfAssetsFolder)lib\net6.0\*.dll" />
10+
<ReferenceCopyLocalPaths Include="$(CustomWpfAssetsFolder)\runtimes\$(CustomWpfRuntimeIdentifier)\native\*.dll" />
11+
</ItemGroup>
12+
</Target>
13+
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
6+
<IncludeBuildOutput>false</IncludeBuildOutput>
7+
<NoPackageAnalysis>true</NoPackageAnalysis>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<None Include="Build\Package.targets" Pack="True" PackagePath="\build\$(PackageId).targets" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\dotnetCampus.CustomWpf.Resource\dotnetCampus.WPF.Resource.csproj" />
16+
</ItemGroup>
17+
</Project>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System;
2+
using System.Runtime.CompilerServices;
3+
using System.Windows;
4+
using System.Windows.Media;
5+
using System.Windows.Media.Composition;
6+
using System.Windows.Navigation;
7+
8+
namespace dotnetCampus.WPF
9+
{
10+
class Program
11+
{
12+
static void Main(string[] args)
13+
{
14+
Application application = new Application();
15+
//NavigationService applicationNavService = application.NavService;
16+
}
17+
}
18+
}
Binary file not shown.
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0-windows</TargetFramework>
5+
<UseWPF>true</UseWPF>
6+
<SignAssembly>True</SignAssembly>
7+
<AssemblyOriginatorKeyFile>dotnet-campus.snk</AssemblyOriginatorKeyFile>
8+
9+
<WpfRepoRoot>..\..\..\</WpfRepoRoot>
10+
11+
<!-- Change based on which assemblies you build (Release/Debug) -->
12+
<WpfConfig>$(Configuration)</WpfConfig>
13+
14+
<WpfOuputFolder Condition="'$(WpfConfig)' == 'Debug'">Microsoft.DotNet.Wpf.GitHub.Debug</WpfOuputFolder>
15+
<WpfOuputFolder Condition="'$(WpfConfig)' == 'Release'">Microsoft.DotNet.Wpf.GitHub</WpfOuputFolder>
16+
</PropertyGroup>
17+
18+
<PropertyGroup>
19+
<EmbedAllSources>true</EmbedAllSources>
20+
<!-- Include symbol files (*.pdb) in the built .nupkg -->
21+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<Reference Include="$(WpfRepoRoot)\artifacts\packaging\$(WpfConfig)\$(WpfOuputFolder)\lib\net6.0\*.dll" />
26+
</ItemGroup>
27+
28+
</Project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<Project>
2+
<PropertyGroup>
3+
<CustomWpfAssetsFolder>$(MSBuildThisFileDirectory)..\Assets\</CustomWpfAssetsFolder>
4+
</PropertyGroup>
5+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<IncludeBuildOutput>false</IncludeBuildOutput>
6+
<NoPackageAnalysis>true</NoPackageAnalysis>
7+
8+
<WpfRepoRoot>..\..\..\</WpfRepoRoot>
9+
10+
<!-- Change based on which assemblies you build (Release/Debug) -->
11+
<WpfConfig>$(Configuration)</WpfConfig>
12+
13+
<WpfOuputFolder Condition="'$(WpfConfig)' == 'Debug'">Microsoft.DotNet.Wpf.GitHub.Debug</WpfOuputFolder>
14+
<WpfOuputFolder Condition="'$(WpfConfig)' == 'Release'">Microsoft.DotNet.Wpf.GitHub</WpfOuputFolder>
15+
16+
<ArtifactsFolder>$(WpfRepoRoot)\artifacts\packaging\$(WpfConfig)\$(WpfOuputFolder)</ArtifactsFolder>
17+
</PropertyGroup>
18+
19+
<ItemGroup>
20+
<None Include="$(ArtifactsFolder)\**\*" Pack="True" PackagePath="\Assets\"></None>
21+
<None Include="Build\Package.props" Pack="True" PackagePath="\build\$(PackageId).props" />
22+
</ItemGroup>
23+
</Project>

CustomWpf/NuGet.config

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<config>
4+
<add key="repositoryPath" value="packages" />
5+
</config>
6+
<packageSources>
7+
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
8+
</packageSources>
9+
</configuration>
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
using System.Reflection;
2+
3+
using dotnetCampus.Configurations;
4+
using dotnetCampus.DotNETBuild.Context;
5+
using dotnetCampus.DotNETBuild.Utils;
6+
using dotnetCampus.GitCommand;
7+
8+
namespace dotnetCampus.WPF.NuGet;
9+
10+
class MainTask
11+
{
12+
public void Run()
13+
{
14+
var appConfigurator = AppConfigurator.GetAppConfigurator();
15+
16+
var commandLineArgs = Environment.GetCommandLineArgs();
17+
appConfigurator.AddCommandLine(commandLineArgs, new Dictionary<string, string>()
18+
{
19+
{"t","Tag" }
20+
});
21+
22+
var tagVersion = appConfigurator.Default["Tag"];
23+
24+
FileSniff fileSniff = new FileSniff(appConfigurator);
25+
fileSniff.Sniff();
26+
27+
// 重新寻找 CustomWpf.sln 所在文件夹
28+
var slnFolder = FindDirectoryByFile(new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!), "CustomWpf.sln")!;
29+
30+
var compileConfiguration = appConfigurator.Of<CompileConfiguration>();
31+
32+
Git git = new Git(new DirectoryInfo(compileConfiguration.CodeDirectory));
33+
var currentCommit = git.GetCurrentCommit();
34+
35+
// 找到 Version 版本号文件
36+
var versionFile = Path.Combine(slnFolder.FullName, @"build\Version.props");
37+
38+
}
39+
40+
/// <summary>
41+
/// 向上寻找到存在某个文件名的文件夹
42+
/// </summary>
43+
/// <param name="currentDirectory"></param>
44+
/// <param name="fileName"></param>
45+
/// <returns></returns>
46+
private static DirectoryInfo FindDirectoryByFile(DirectoryInfo currentDirectory, string fileName)
47+
{
48+
var directory = currentDirectory;
49+
while (directory != null)
50+
{
51+
var file = Path.Combine(directory.FullName, fileName);
52+
if (File.Exists(file))
53+
{
54+
return directory;
55+
}
56+
else
57+
{
58+
directory = directory.Parent;
59+
}
60+
}
61+
62+
throw new ArgumentException($"Can not find any Directory. CurrentDirectory =\"{currentDirectory}\";FileName=\"{fileName}\"");
63+
}
64+
}

0 commit comments

Comments
 (0)