Skip to content

Commit

Permalink
Merge pull request #1 from dotnet-campus/t/lindexi/CustomWpf
Browse files Browse the repository at this point in the history
自定义的私有发布版本
  • Loading branch information
kkwpsv authored May 9, 2022
2 parents 14a1e0e + b47e528 commit 419ec41
Show file tree
Hide file tree
Showing 21 changed files with 432 additions and 20 deletions.
50 changes: 30 additions & 20 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,42 @@ jobs:

steps:
- uses: actions/checkout@v1
# - name: Install Nuget
# uses: nuget/setup-nuget@v1
# with:
# nuget-version: '5.x'
- name: Build
run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86
- name: Push
uses: actions/upload-artifact@v1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
name: WPF_Debug
path: ./artifacts/packages/Debug/NonShipping
dotnet-version: |
3.1.x
5.0.x
6.0.101
- name: Build WPF
run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86
- name: Build CustomWPF
run: dotnet build CustomWpf
# - name: Push
# uses: actions/upload-artifact@v1
# with:
# name: WPF_Debug
# path: ./artifacts/packages/Debug/NonShipping

BuildRelease:

runs-on: windows-latest

steps:
- uses: actions/checkout@v1
# - name: Install Nuget
# uses: nuget/setup-nuget@v1
# with:
# nuget-version: '5.x'
- name: Build
run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86
- name: Push
uses: actions/upload-artifact@v1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
name: WPF_Release
path: ./artifacts/packages/Release/NonShipping
dotnet-version: |
3.1.x
5.0.x
6.0.101
- name: Build WPF
run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86
- name: Build CustomWPF
run: dotnet build CustomWpf -c Release
# - name: Push
# uses: actions/upload-artifact@v1
# with:
# name: WPF_Release
# path: ./artifacts/packages/Release/NonShipping
65 changes: 65 additions & 0 deletions .github/workflows/NuGet-Tag-Publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Publish Custom WPF

on:
push:
tags:
- '*'

jobs:
# BuildDebug:

# runs-on: windows-latest

# steps:
# - uses: actions/checkout@v1
# # - name: Install Nuget
# # uses: nuget/setup-nuget@v1
# # with:
# # nuget-version: '5.x'
# - name: Build
# run: .\build.cmd -pack -ci -configuration Debug -prepareMachine /p:Platform=x86
# - name: Push
# uses: actions/upload-artifact@v1
# with:
# name: WPF_Debug
# path: ./artifacts/packages/Debug/NonShipping

Build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v1
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: |
3.1.x
5.0.x
6.0.101
- name: Install Tools
run: dotnet tool install -g dotnetCampus.TagToVersion --add-source https://api.nuget.org/v3/index.json
- name: Set Package TagToVersion
run: dotnet tagtoversion -t ${{ github.ref }} -f CustomWpf\build\Version.props
- name: Build WPF
run: .\build.cmd -pack -ci -configuration Release -prepareMachine /p:Platform=x86
- name: Pack NuGet
run: dotnet pack CustomWpf -c release

- name: Install Nuget
uses: nuget/setup-nuget@v1
with:
nuget-version: '5.x'
- name: Add private GitHub registry to NuGet
run: |
nuget sources add -name github -Source https://nuget.pkg.github.com/dotnet-campus/index.json -Username dotnet-campus -Password ${{ secrets.GITHUB_TOKEN }}
- name: Push NuGet Package
run: |
nuget push .\CustomWpf\bin\Release\*.nupkg -Source github -SkipDuplicate
nuget push .\CustomWpf\bin\Release\*.nupkg -Source https://api.nuget.org/v3/index.json -SkipDuplicate -ApiKey ${{ secrets.NugetKey }}
# - name: Push
# uses: actions/upload-artifact@v1
# with:
# name: WPF_Release
# path: ./artifacts/packages/Release/NonShipping
58 changes: 58 additions & 0 deletions CustomWpf/CustomWpf.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.WPF", "Lib\dotnetCampus.CustomWpf.Lib\dotnetCampus.WPF.csproj", "{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Lib", "Lib", "{FE032A91-A790-4274-A194-02E161D1F14B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Packaging", "Packaging", "{27886E90-E328-4AE9-86DA-1F596554D26B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.WPF.NuGet", "Packaging\dotnetCampus.WPF.NuGet\dotnetCampus.WPF.NuGet.csproj", "{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnetCampus.WPF.Resource", "Lib\dotnetCampus.CustomWpf.Resource\dotnetCampus.WPF.Resource.csproj", "{D73CB485-6290-4E37-B441-8068E60CBF7E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{315B416C-6CDA-4CD5-9666-69C8272CD80E}"
ProjectSection(SolutionItems) = preProject
build\Version.props = build\Version.props
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dotnetCampus.WPF.Dependencies", "Lib\dotnetCampus.CustomWpf.Dependencies\dotnetCampus.WPF.Dependencies.csproj", "{39E01A9E-C352-4B7E-96CA-612A07937470}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C}.Release|Any CPU.Build.0 = Release|Any CPU
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F}.Release|Any CPU.Build.0 = Release|Any CPU
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D73CB485-6290-4E37-B441-8068E60CBF7E}.Release|Any CPU.Build.0 = Release|Any CPU
{39E01A9E-C352-4B7E-96CA-612A07937470}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39E01A9E-C352-4B7E-96CA-612A07937470}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39E01A9E-C352-4B7E-96CA-612A07937470}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39E01A9E-C352-4B7E-96CA-612A07937470}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{39764FE3-C2F9-4772-9BF6-B66923ABEC4C} = {FE032A91-A790-4274-A194-02E161D1F14B}
{FDC9151F-3544-4C68-9D05-D8E4935F1A9F} = {27886E90-E328-4AE9-86DA-1F596554D26B}
{D73CB485-6290-4E37-B441-8068E60CBF7E} = {FE032A91-A790-4274-A194-02E161D1F14B}
{39E01A9E-C352-4B7E-96CA-612A07937470} = {FE032A91-A790-4274-A194-02E161D1F14B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C25E6016-F278-457B-87D6-39EC0E0A6849}
EndGlobalSection
EndGlobal
18 changes: 18 additions & 0 deletions CustomWpf/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project>
<Import Project="build\Version.props" />
<PropertyGroup>
<LangVersion>latest</LangVersion>
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\$(Configuration)</PackageOutputPath>
<Company>dotnet campus(.NET 职业技术学院)</Company>

<Authors>dotnet-campus</Authors>
<RepositoryUrl>https://github.com/dotnet-campus/dotnetCampus.Ipc</RepositoryUrl>
<PackageProjectUrl>https://github.com/dotnet-campus/dotnetCampus.Ipc</PackageProjectUrl>
<Description>包含定制的 WPF 版本</Description>

<RepositoryType>git</RepositoryType>
<Copyright>Copyright © 2020-2022 dotnet campus, All Rights Reserved.</Copyright>
</PropertyGroup>


</Project>
3 changes: 3 additions & 0 deletions CustomWpf/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<Target Name="CustomWpfResolveReferences"
BeforeTargets="ResolveReferences">
<PropertyGroup>
<CustomWpfRuntimeIdentifier Condition="'$(CustomWpfRuntimeIdentifier)' == ''">$(RuntimeIdentifier)</CustomWpfRuntimeIdentifier>
<CustomWpfRuntimeIdentifier Condition="'$(CustomWpfRuntimeIdentifier)' == ''">win-x86</CustomWpfRuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<ReferenceCopyLocalPaths Include="$(CustomWpfAssetsFolder)lib\net6.0\*.dll" />
<ReferenceCopyLocalPaths Include="$(CustomWpfAssetsFolder)\runtimes\$(CustomWpfRuntimeIdentifier)\native\*.dll" />
</ItemGroup>
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>

<IncludeBuildOutput>false</IncludeBuildOutput>
<NoPackageAnalysis>true</NoPackageAnalysis>
</PropertyGroup>

<ItemGroup>
<None Include="Build\Package.targets" Pack="True" PackagePath="\build\$(PackageId).targets" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\dotnetCampus.CustomWpf.Resource\dotnetCampus.WPF.Resource.csproj" />
</ItemGroup>
</Project>
18 changes: 18 additions & 0 deletions CustomWpf/Lib/dotnetCampus.CustomWpf.Lib/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Composition;
using System.Windows.Navigation;

namespace dotnetCampus.WPF
{
class Program
{
static void Main(string[] args)
{
Application application = new Application();
//NavigationService applicationNavService = application.NavService;
}
}
}
Binary file not shown.
Binary file not shown.
28 changes: 28 additions & 0 deletions CustomWpf/Lib/dotnetCampus.CustomWpf.Lib/dotnetCampus.WPF.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<SignAssembly>True</SignAssembly>
<AssemblyOriginatorKeyFile>dotnet-campus.snk</AssemblyOriginatorKeyFile>

<WpfRepoRoot>..\..\..\</WpfRepoRoot>

<!-- Change based on which assemblies you build (Release/Debug) -->
<WpfConfig>$(Configuration)</WpfConfig>

<WpfOuputFolder Condition="'$(WpfConfig)' == 'Debug'">Microsoft.DotNet.Wpf.GitHub.Debug</WpfOuputFolder>
<WpfOuputFolder Condition="'$(WpfConfig)' == 'Release'">Microsoft.DotNet.Wpf.GitHub</WpfOuputFolder>
</PropertyGroup>

<PropertyGroup>
<EmbedAllSources>true</EmbedAllSources>
<!-- Include symbol files (*.pdb) in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>

<ItemGroup>
<Reference Include="$(WpfRepoRoot)\artifacts\packaging\$(WpfConfig)\$(WpfOuputFolder)\lib\net6.0\*.dll" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<CustomWpfAssetsFolder>$(MSBuildThisFileDirectory)..\Assets\</CustomWpfAssetsFolder>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
<NoPackageAnalysis>true</NoPackageAnalysis>

<WpfRepoRoot>..\..\..\</WpfRepoRoot>

<!-- Change based on which assemblies you build (Release/Debug) -->
<WpfConfig>$(Configuration)</WpfConfig>

<WpfOuputFolder Condition="'$(WpfConfig)' == 'Debug'">Microsoft.DotNet.Wpf.GitHub.Debug</WpfOuputFolder>
<WpfOuputFolder Condition="'$(WpfConfig)' == 'Release'">Microsoft.DotNet.Wpf.GitHub</WpfOuputFolder>

<ArtifactsFolder>$(WpfRepoRoot)\artifacts\packaging\$(WpfConfig)\$(WpfOuputFolder)</ArtifactsFolder>
</PropertyGroup>

<ItemGroup>
<None Include="$(ArtifactsFolder)\**\*" Pack="True" PackagePath="\Assets\"></None>
<None Include="Build\Package.props" Pack="True" PackagePath="\build\$(PackageId).props" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions CustomWpf/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<add key="repositoryPath" value="packages" />
</config>
<packageSources>
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
64 changes: 64 additions & 0 deletions CustomWpf/Packaging/dotnetCampus.WPF.NuGet/MainTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System.Reflection;

using dotnetCampus.Configurations;
using dotnetCampus.DotNETBuild.Context;
using dotnetCampus.DotNETBuild.Utils;
using dotnetCampus.GitCommand;

namespace dotnetCampus.WPF.NuGet;

class MainTask
{
public void Run()
{
var appConfigurator = AppConfigurator.GetAppConfigurator();

var commandLineArgs = Environment.GetCommandLineArgs();
appConfigurator.AddCommandLine(commandLineArgs, new Dictionary<string, string>()
{
{"t","Tag" }
});

var tagVersion = appConfigurator.Default["Tag"];

FileSniff fileSniff = new FileSniff(appConfigurator);
fileSniff.Sniff();

// 重新寻找 CustomWpf.sln 所在文件夹
var slnFolder = FindDirectoryByFile(new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!), "CustomWpf.sln")!;

var compileConfiguration = appConfigurator.Of<CompileConfiguration>();

Git git = new Git(new DirectoryInfo(compileConfiguration.CodeDirectory));
var currentCommit = git.GetCurrentCommit();

// 找到 Version 版本号文件
var versionFile = Path.Combine(slnFolder.FullName, @"build\Version.props");

}

/// <summary>
/// 向上寻找到存在某个文件名的文件夹
/// </summary>
/// <param name="currentDirectory"></param>
/// <param name="fileName"></param>
/// <returns></returns>
private static DirectoryInfo FindDirectoryByFile(DirectoryInfo currentDirectory, string fileName)
{
var directory = currentDirectory;
while (directory != null)
{
var file = Path.Combine(directory.FullName, fileName);
if (File.Exists(file))
{
return directory;
}
else
{
directory = directory.Parent;
}
}

throw new ArgumentException($"Can not find any Directory. CurrentDirectory =\"{currentDirectory}\";FileName=\"{fileName}\"");
}
}
Loading

0 comments on commit 419ec41

Please sign in to comment.