This commit is contained in:
Alexandre Zollinger Chohfi 2021-03-30 13:47:16 -07:00
Родитель 8060f01ab1
Коммит 7b1f20c12d
22 изменённых файлов: 760 добавлений и 102 удалений

1
.gitignore поставляемый
Просмотреть файл

@ -290,5 +290,6 @@ __pycache__/
*.odx.cs
*.xsd.cs
/build/tools
/build/nupkg
BuildResults.xml

Просмотреть файл

@ -19,5 +19,5 @@
<DebugType>full</DebugType>
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
</Project>

Просмотреть файл

@ -1,9 +1,15 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
#if WINUI
using Microsoft.UI.Xaml.Media;
namespace ColorCode.WinUI.Common
#else
using Windows.UI.Xaml.Media;
namespace ColorCode.UWP.Common
#endif
{
public static class ExtensionMethods
{

Просмотреть файл

@ -2,13 +2,21 @@
using System.Collections.Generic;
using ColorCode.Parsing;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
using ColorCode.Styling;
using Windows.UI.Text;
using ColorCode.UWP.Common;
using ColorCode.Common;
#if WINUI
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Documents;
using ColorCode.WinUI.Common;
using Microsoft.UI.Xaml;
using Microsoft.UI.Text;
#else
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
using ColorCode.UWP.Common;
using Windows.UI.Xaml;
#endif
namespace ColorCode
{

Просмотреть файл

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
<SupportedOSPlatformVersion>$(TargetPlatformMinVersion)</SupportedOSPlatformVersion>
<RootNamespace>ColorCode</RootNamespace>
<AssemblyName>ColorCode.WinUI</AssemblyName>
<Title>ColorCode.WinUI</Title>
<Description>Contains the RichTextBlockFormatter, for rendering the Colorized Code to a RichTextBlock.</Description>
<PackageTags>ColorCode Syntax Highlighting SyntaxHighlighting Formatting UWP RichTextBlock Document InlineCollection</PackageTags>
<DefineConstants>$(DefineConstants);WINUI</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\ColorCode.UWP\Common\ExtensionMethods.cs" Link="Common\ExtensionMethods.cs" />
<Compile Include="..\ColorCode.UWP\RichTextBlockFormatter.cs" Link="RichTextBlockFormatter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ColorCode.Core\ColorCode.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Common\" />
</ItemGroup>
</Project>

Просмотреть файл

@ -7,13 +7,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.HTML", "ColorCode
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{5B9F207C-2EAB-4F77-95C7-206D65C87137}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.UWP", "ColorCode.UWP\ColorCode.UWP.csproj", "{A482CFCC-D474-4C43-A812-1B0B4E6E484F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.Core", "ColorCode.Core\ColorCode.Core.csproj", "{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.BasicTests", "Tests\ColorCode.BasicTests\ColorCode.BasicTests.csproj", "{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorCode.UWPTests", "Tests\ColorCode.UWPTests\ColorCode.UWPTests.csproj", "{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.WinUITests", "Tests\ColorCode.WinUITests\ColorCode.WinUITests.csproj", "{F1ED6BD6-2690-4BF3-835C-C3927C33424F}"
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "ColorCode.WinUITests (Package)", "Tests\ColorCode.WinUITests (Package)\ColorCode.WinUITests (Package).wapproj", "{DD20D31A-915E-43A2-B819-3A7AE39CA25C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.WinUI", "ColorCode.WinUI\ColorCode.WinUI.csproj", "{5B043ED5-3662-4CE5-9004-637E1739C363}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{A4B1B99B-FC3A-4C76-8B46-B96723829FD2}"
ProjectSection(SolutionItems) = preProject
@ -25,14 +27,20 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
version.json = version.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorCode.UWP", "ColorCode.UWP\ColorCode.UWP.csproj", "{9A628641-BF6E-439F-AF60-BF9E471D45AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorCode.UWPTests", "Tests\ColorCode.UWPTests\ColorCode.UWPTests.csproj", "{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|ARM64 = Debug|ARM64
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|ARM64 = Release|ARM64
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
@ -41,6 +49,8 @@ Global
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|ARM.ActiveCfg = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|ARM.Build.0 = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|ARM64.Build.0 = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|x64.ActiveCfg = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|x64.Build.0 = Debug|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -49,30 +59,18 @@ Global
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|Any CPU.Build.0 = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|ARM.ActiveCfg = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|ARM.Build.0 = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|ARM64.ActiveCfg = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|ARM64.Build.0 = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|x64.ActiveCfg = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|x64.Build.0 = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|x86.ActiveCfg = Release|Any CPU
{33A3FB96-F1EB-4AF0-94E0-F629E1F574A8}.Release|x86.Build.0 = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|ARM.ActiveCfg = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|ARM.Build.0 = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|x64.ActiveCfg = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|x64.Build.0 = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|x86.ActiveCfg = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Debug|x86.Build.0 = Debug|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|Any CPU.Build.0 = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|ARM.ActiveCfg = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|ARM.Build.0 = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|x64.ActiveCfg = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|x64.Build.0 = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|x86.ActiveCfg = Release|Any CPU
{A482CFCC-D474-4C43-A812-1B0B4E6E484F}.Release|x86.Build.0 = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|ARM.ActiveCfg = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|ARM.Build.0 = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|ARM64.Build.0 = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|x64.ActiveCfg = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|x64.Build.0 = Debug|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -81,6 +79,8 @@ Global
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|Any CPU.Build.0 = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|ARM.ActiveCfg = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|ARM.Build.0 = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|ARM64.ActiveCfg = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|ARM64.Build.0 = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|x64.ActiveCfg = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|x64.Build.0 = Release|Any CPU
{F6DE802C-9BD7-4BFA-9553-BCBF51E0556B}.Release|x86.ActiveCfg = Release|Any CPU
@ -89,6 +89,8 @@ Global
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|ARM.ActiveCfg = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|ARM.Build.0 = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|ARM64.Build.0 = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|x64.ActiveCfg = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|x64.Build.0 = Debug|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Debug|x86.ActiveCfg = Debug|Any CPU
@ -96,14 +98,91 @@ Global
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|ARM.ActiveCfg = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|ARM.Build.0 = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|ARM64.ActiveCfg = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|ARM64.Build.0 = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|x64.ActiveCfg = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|x64.Build.0 = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|x86.ActiveCfg = Release|Any CPU
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10}.Release|x86.Build.0 = Release|Any CPU
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|Any CPU.ActiveCfg = Debug|x64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|ARM.ActiveCfg = Debug|x86
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|ARM64.ActiveCfg = Debug|arm64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|ARM64.Build.0 = Debug|arm64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|x64.ActiveCfg = Debug|x64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|x64.Build.0 = Debug|x64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|x86.ActiveCfg = Debug|x86
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Debug|x86.Build.0 = Debug|x86
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|Any CPU.ActiveCfg = Release|x64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|ARM.ActiveCfg = Release|x86
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|ARM64.ActiveCfg = Release|x86
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|x64.ActiveCfg = Release|x64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|x64.Build.0 = Release|x64
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|x86.ActiveCfg = Release|x86
{F1ED6BD6-2690-4BF3-835C-C3927C33424F}.Release|x86.Build.0 = Release|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|Any CPU.ActiveCfg = Debug|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|ARM.ActiveCfg = Debug|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|ARM64.ActiveCfg = Debug|ARM64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|ARM64.Build.0 = Debug|ARM64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|x64.ActiveCfg = Debug|x64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|x64.Build.0 = Debug|x64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|x64.Deploy.0 = Debug|x64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|x86.ActiveCfg = Debug|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|x86.Build.0 = Debug|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Debug|x86.Deploy.0 = Debug|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|Any CPU.ActiveCfg = Release|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|ARM.ActiveCfg = Release|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|ARM64.ActiveCfg = Release|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|x64.ActiveCfg = Release|x64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|x64.Build.0 = Release|x64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|x64.Deploy.0 = Release|x64
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|x86.ActiveCfg = Release|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|x86.Build.0 = Release|x86
{DD20D31A-915E-43A2-B819-3A7AE39CA25C}.Release|x86.Deploy.0 = Release|x86
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|ARM.ActiveCfg = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|ARM.Build.0 = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|ARM64.Build.0 = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|x64.ActiveCfg = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|x64.Build.0 = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Debug|x86.Build.0 = Debug|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|Any CPU.Build.0 = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|ARM.ActiveCfg = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|ARM.Build.0 = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|ARM64.ActiveCfg = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|ARM64.Build.0 = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|x64.ActiveCfg = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|x64.Build.0 = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|x86.ActiveCfg = Release|Any CPU
{5B043ED5-3662-4CE5-9004-637E1739C363}.Release|x86.Build.0 = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|ARM.ActiveCfg = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|ARM.Build.0 = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|ARM64.Build.0 = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|x64.ActiveCfg = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|x64.Build.0 = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|x86.ActiveCfg = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Debug|x86.Build.0 = Debug|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|Any CPU.Build.0 = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|ARM.ActiveCfg = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|ARM.Build.0 = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|ARM64.ActiveCfg = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|ARM64.Build.0 = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|x64.ActiveCfg = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|x64.Build.0 = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|x86.ActiveCfg = Release|Any CPU
{9A628641-BF6E-439F-AF60-BF9E471D45AF}.Release|x86.Build.0 = Release|Any CPU
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|Any CPU.ActiveCfg = Debug|x86
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|ARM.ActiveCfg = Debug|ARM
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|ARM.Build.0 = Debug|ARM
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|ARM.Deploy.0 = Debug|ARM
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|ARM64.ActiveCfg = Debug|x86
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|x64.ActiveCfg = Debug|x64
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|x64.Build.0 = Debug|x64
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Debug|x64.Deploy.0 = Debug|x64
@ -114,6 +193,7 @@ Global
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|ARM.ActiveCfg = Release|ARM
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|ARM.Build.0 = Release|ARM
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|ARM.Deploy.0 = Release|ARM
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|ARM64.ActiveCfg = Release|x86
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|x64.ActiveCfg = Release|x64
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|x64.Build.0 = Release|x64
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3}.Release|x64.Deploy.0 = Release|x64
@ -126,6 +206,8 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A3E27CD2-6D33-44D3-962F-E56C4CD25F10} = {5B9F207C-2EAB-4F77-95C7-206D65C87137}
{F1ED6BD6-2690-4BF3-835C-C3927C33424F} = {5B9F207C-2EAB-4F77-95C7-206D65C87137}
{DD20D31A-915E-43A2-B819-3A7AE39CA25C} = {5B9F207C-2EAB-4F77-95C7-206D65C87137}
{A3D5A8A5-1D1F-412D-A829-C3DC1C7D4DF3} = {5B9F207C-2EAB-4F77-95C7-206D65C87137}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution

Просмотреть файл

@ -9,24 +9,50 @@
<Copyright>Copyright © Microsoft Corporation, William Bradley 2017</Copyright>
<!-- Project States -->
<IsUwpProject>$(MSBuildProjectName.Contains('UWP'))</IsUwpProject>
<IsWinUIProject>$(MSBuildProjectName.Contains('WinUI'))</IsWinUIProject>
<IsTestProject>$(MSBuildProjectName.Contains('Test'))</IsTestProject>
<!-- UWP Config -->
</PropertyGroup>
<!-- UWP Config -->
<PropertyGroup Condition="'$(IsUwpProject)' == 'true'">
<TargetPlatformVersion>10.0.16299.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.14393.0</TargetPlatformMinVersion>
</PropertyGroup>
<!-- WinUI Config -->
<PropertyGroup Condition="'$(IsWinUIProject)' == 'true'">
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
<Choose>
<When Condition="'$(IsUwpProject)' == 'true' and '$(SourceLinkEnabled)' != 'false' and '$(IsTestProject)' != 'true'">
<When Condition="('$(IsWinUIProject)' == 'true' or '$(IsUwpProject)' == 'true') and '$(SourceLinkEnabled)' != 'false' and '$(IsTestProject)' != 'true'">
<PropertyGroup>
<GenerateLibraryLayout>true</GenerateLibraryLayout>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.0.9" PrivateAssets="all" />
</ItemGroup>
</When>
</Choose>
<Choose>
<When Condition="'$(IsWinUIProject)' == 'true'">
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="0.5.0" />
</ItemGroup>
</When>
</Choose>
<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.1.23" PrivateAssets="all" />
</ItemGroup>

Просмотреть файл

@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Просмотреть файл

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|arm64">
<Configuration>Debug</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|arm64">
<Configuration>Release</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<PathToXAMLWinRTImplementations>ColorCode.WinUITests\</PathToXAMLWinRTImplementations>
<AssetTargetFallback>net5.0-windows$(TargetPlatformVersion);$(AssetTargetFallback)</AssetTargetFallback>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>dd20d31a-915e-43a2-b819-3a7ae39ca25c</ProjectGuid>
<TargetPlatformVersion>10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\ColorCode.WinUITests\ColorCode.WinUITests.csproj</EntryPointProjectUniqueName>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="..\ColorCode.UWPTests\Assets\LockScreenLogo.scale-200.png">
<Link>Images\LockScreenLogo.scale-200.png</Link>
</Content>
<Content Include="..\ColorCode.UWPTests\Assets\SplashScreen.scale-200.png">
<Link>Images\SplashScreen.scale-200.png</Link>
</Content>
<Content Include="..\ColorCode.UWPTests\Assets\Square150x150Logo.scale-200.png">
<Link>Images\Square150x150Logo.scale-200.png</Link>
</Content>
<Content Include="..\ColorCode.UWPTests\Assets\Square44x44Logo.scale-200.png">
<Link>Images\Square44x44Logo.scale-200.png</Link>
</Content>
<Content Include="..\ColorCode.UWPTests\Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
<Link>Images\Square44x44Logo.targetsize-24_altform-unplated.png</Link>
</Content>
<Content Include="..\ColorCode.UWPTests\Assets\StoreLogo.png">
<Link>Images\StoreLogo.png</Link>
</Content>
<Content Include="..\ColorCode.UWPTests\Assets\Wide310x150Logo.scale-200.png">
<Link>Images\Wide310x150Logo.scale-200.png</Link>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ColorCode.WinUITests\ColorCode.WinUITests.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ProjectReunion" Version="[0.5.0]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="[0.5.0]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>

Просмотреть файл

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity
Name="0f38d22e-c4ee-40d4-91e4-70ff099e91e3"
Publisher="CN=alzollin"
Version="1.0.0.0" />
<Properties>
<DisplayName>ColorCode.WinUITests (Package)</DisplayName>
<PublisherDisplayName>alzollin</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.18362.0" />
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.18362.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="ColorCode.WinUITests (Package)"
Description="ColorCode.WinUITests (Package)"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

Просмотреть файл

@ -0,0 +1,15 @@
<Application
x:Class="ColorCode.WinUITests.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ColorCode.WinUITests">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
<!-- Other merged dictionaries here -->
</ResourceDictionary.MergedDictionaries>
<!-- Other app resources here -->
</ResourceDictionary>
</Application.Resources>
</Application>

Просмотреть файл

@ -0,0 +1,63 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
using System;
using Windows.ApplicationModel;
using Microsoft.UI.Xaml;
using WinRT;
using System.Runtime.InteropServices;
namespace ColorCode.WinUITests
{
/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
public partial class App : Application
{
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
this.InitializeComponent();
//this.Suspending += OnSuspending;
}
/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
IWindowNative windowWrapper = m_window.As<IWindowNative>();
WindowHandle = windowWrapper.WindowHandle;
m_window.Activate();
}
public IntPtr WindowHandle { get; private set; }
[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("EECDBF0E-BAE9-4CB6-A68E-9598E1CB57BB")]
internal interface IWindowNative
{
IntPtr WindowHandle { get; }
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">The source of the suspend request.</param>
/// <param name="e">Details about the suspend request.</param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
// Save application state and stop any background activity
}
private Window m_window;
}
}

Просмотреть файл

@ -0,0 +1,25 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion>$(TargetPlatformMinVersion)</SupportedOSPlatformVersion>
<RootNamespace>ColorCode.WinUITests</RootNamespace>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x86;x64;arm64</Platforms>
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<Manifest Include="$(ApplicationManifest)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ColorCode.Core\ColorCode.Core.csproj" />
<ProjectReference Include="..\..\ColorCode.HTML\ColorCode.HTML.csproj" />
<ProjectReference Include="..\..\ColorCode.WinUI\ColorCode.WinUI.csproj" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,28 @@
<Window
x:Class="ColorCode.WinUITests.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:ColorCode.WinUITests"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid x:Name="MainGrid" Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<ScrollViewer VerticalScrollMode="Disabled" HorizontalScrollBarVisibility="Auto" HorizontalScrollMode="Auto">
<StackPanel Orientation="Horizontal">
<Button Content="Render to Rich Text Block Light Theme" Click="RenderLight" Margin="5" />
<Button Content="Render to Rich Text Block Dark Theme" Click="RenderDark" Margin="5" />
<Button Content="Create HTML Light Theme" Click="HTMLLight" Margin="5" />
<Button Content="Create HTML Dark Theme" Click="HTMLDark" Margin="5" />
</StackPanel>
</ScrollViewer>
<ScrollViewer Grid.Row="1" IsHorizontalRailEnabled="True" HorizontalScrollMode="Auto" HorizontalScrollBarVisibility="Auto">
<RichTextBlock x:Name="PresentationBlock" FontFamily="Consolas" />
</ScrollViewer>
</Grid>
</Window>

Просмотреть файл

@ -0,0 +1,123 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
using ColorCode.Common;
using ColorCode.Styling;
using ColorCode.WinUI.Common;
using System;
using System.IO;
using System.Threading.Tasks;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.System;
using Microsoft.UI.Xaml;
using System.Runtime.InteropServices;
using WinRT;
namespace ColorCode.WinUITests
{
public sealed partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
#region IInitializeWithWindow
[ComImport]
[Guid("3E68D4BD-7135-4D10-8018-9FB6D9F33FA1")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IInitializeWithWindow
{
void Initialize(IntPtr hwnd);
}
#endregion
private async Task<Tuple<string, ILanguage>> GetCodeFileText()
{
try
{
var picker = new FileOpenPicker();
IntPtr windowHandle = (App.Current as App).WindowHandle;
IInitializeWithWindow initializeWithWindowWrapper = picker.As<IInitializeWithWindow>();
initializeWithWindowWrapper.Initialize(windowHandle);
picker.FileTypeFilter.Add("*");
var file = await picker.PickSingleFileAsync();
if (file == null) return null;
System.Diagnostics.Debugger.Launch();
string text = "";
using (var reader = new StreamReader(await file.OpenStreamForReadAsync(), true))
{
text = await reader.ReadToEndAsync();
}
ILanguage Language = Languages.FindById(file.FileType.Replace(".", "")) ?? Languages.CSharp;
return new Tuple<string, ILanguage>(text, Language);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
return new Tuple<string, ILanguage>("ERROR", Languages.CSharp);
}
}
private void RenderLight(object sender, RoutedEventArgs e)
{
MainGrid.RequestedTheme = ElementTheme.Light;
Render();
}
private void RenderDark(object sender, RoutedEventArgs e)
{
MainGrid.RequestedTheme = ElementTheme.Dark;
Render();
}
private async void Render()
{
PresentationBlock.Blocks.Clear();
var result = await GetCodeFileText();
if (result == null) return;
var formatter = new RichTextBlockFormatter(MainGrid.RequestedTheme);
var plainText = formatter.Styles[ScopeName.PlainText];
MainGrid.Background = (plainText?.Background ?? StyleDictionary.White).GetSolidColorBrush();
formatter.FormatRichTextBlock(result.Item1, result.Item2, PresentationBlock);
}
private void HTMLLight(object sender, RoutedEventArgs e)
{
MakeHTML(StyleDictionary.DefaultLight);
}
private void HTMLDark(object sender, RoutedEventArgs e)
{
MakeHTML(StyleDictionary.DefaultDark);
}
private async void MakeHTML(StyleDictionary Styles)
{
var result = await GetCodeFileText();
if (result == null) return;
var formatter = new HtmlFormatter(Styles);
var html = formatter.GetHtmlString(result.Item1, result.Item2);
var tempfile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync("HTMLResult.html", CreationCollisionOption.ReplaceExisting);
await FileIO.WriteTextAsync(tempfile, html);
try
{
await Launcher.LaunchFileAsync(tempfile);
}
catch { }
}
}
}

Просмотреть файл

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="ColorCode.WinUITests.app"/>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<!-- The combination of below two tags have the following effect:
1) Per-Monitor for >= Windows 10 Anniversary Update
2) System < Windows 10 Anniversary Update
-->
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/PM</dpiAware>
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2, PerMonitor</dpiAwareness>
</windowsSettings>
</application>
</assembly>

Просмотреть файл

@ -21,9 +21,9 @@ steps:
displayName: Setup Environment Variables
- task: NuGetToolInstaller@1
displayName: Use NuGet 5.5.1
displayName: Use NuGet 5.8.1
inputs:
versionSpec: 5.5.1
versionSpec: 5.8.1
- task: DotNetCoreCLI@2
inputs:
@ -35,6 +35,19 @@ steps:
- script: nbgv cloud
displayName: Set Version
- task: UseDotNet@2
displayName: 'Install .NET Core SDK'
inputs:
version: 5.0.201
performMultiLevelLookup: true
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: msbuild
arguments: /t:restore .\ColorCode.sln
displayName: NuGet restore
- powershell: .\build\build.ps1
displayName: Build

Просмотреть файл

@ -1,7 +1,10 @@
#module nuget:?package=Cake.LongPath.Module&version=0.7.0
#module nuget:?package=Cake.LongPath.Module&version=1.0.1
#addin nuget:?package=Cake.FileHelpers&version=3.2.1
#addin nuget:?package=Cake.Powershell&version=0.4.8
#addin nuget:?package=Cake.FileHelpers&version=4.0.1
#addin nuget:?package=Cake.Powershell&version=1.0.0
#addin nuget:?package=Cake.GitVersioning&version=3.3.37
#tool nuget:?package=vswhere&version=2.8.4
using System;
using System.Linq;
@ -19,13 +22,10 @@ var target = Argument("target", "Default");
var baseDir = MakeAbsolute(Directory("../")).ToString();
var buildDir = baseDir + "/build";
var toolsDir = buildDir + "/tools";
var Solution = baseDir + "/ColorCode.sln";
var nupkgDir = buildDir + "/nupkg";
var gitVersioningVersion = "2.1.65";
var versionClient = toolsDir + "/nerdbank.gitversioning/tools/Get-Version.ps1";
string Version = null;
//////////////////////////////////////////////////////////////////////
@ -80,12 +80,24 @@ void VerifyHeaders(bool Replace)
void RetrieveVersion()
{
Information("\nRetrieving version...");
var results = StartPowershellFile(versionClient);
Version = results[1].Properties["NuGetPackageVersion"].Value.ToString();
Information("\nRetrieving version...");
Version = GitVersioningGetVersion().NuGetPackageVersion;
Information("\nBuild Version: " + Version);
}
void UpdateToolsPath(MSBuildSettings buildSettings)
{
// Workaround for https://github.com/cake-build/cake/issues/2128
var vsInstallation = VSWhereLatest(new VSWhereLatestSettings { Requires = "Microsoft.Component.MSBuild", IncludePrerelease = true });
if (vsInstallation != null)
{
buildSettings.ToolPath = vsInstallation.CombineWithFilePath(@"MSBuild\Current\Bin\MSBuild.exe");
if (!FileExists(buildSettings.ToolPath))
buildSettings.ToolPath = vsInstallation.CombineWithFilePath(@"MSBuild\15.0\Bin\MSBuild.exe");
}
}
//////////////////////////////////////////////////////////////////////
// TASKS
//////////////////////////////////////////////////////////////////////
@ -101,7 +113,7 @@ Task("Restore-NuGet-Packages")
.IsDependentOn("Clean")
.Does(() =>
{
NuGetRestore(Solution);
DotNetCoreRestore(Solution);
});
Task("Verify")
@ -120,15 +132,6 @@ Task("Version")
.IsDependentOn("Restore-NuGet-Packages")
.Does(() =>
{
Information("\nDownloading NerdBank GitVersioning...");
var installSettings = new NuGetInstallSettings {
ExcludeVersion = true,
Version = gitVersioningVersion,
OutputDirectory = toolsDir
};
NuGetInstall(new []{"nerdbank.gitversioning"}, installSettings);
RetrieveVersion();
});
@ -142,13 +145,16 @@ Task("Build")
MaxCpuCount = 0
}
.SetConfiguration("Release")
.WithTarget("Restore;Build")
.WithTarget("Pack")
.WithProperty("IncludeSymbols", "true")
.WithProperty("GenerateLibraryLayout", "true")
.WithProperty("PackageOutputPath", nupkgDir)
.WithProperty("GeneratePackageOnBuild", "true");
.WithProperty("SymbolPackageFormat", "snupkg");
UpdateToolsPath(buildSettings);
EnsureDirectoryExists(nupkgDir);
MSBuild(Solution, buildSettings);
});

Просмотреть файл

@ -21,40 +21,57 @@ The build script target to run.
The build configuration to use.
.PARAMETER Verbosity
Specifies the amount of information to be displayed.
.PARAMETER Experimental
Tells Cake to use the latest Roslyn release.
.PARAMETER WhatIf
Performs a dry run of the build script.
No tasks will be executed.
.PARAMETER Mono
Tells Cake to use the Mono scripting engine.
.PARAMETER ShowDescription
Shows description about tasks.
.PARAMETER DryRun
Performs a dry run.
.PARAMETER SkipToolPackageRestore
Skips restoring of packages.
.PARAMETER ScriptArgs
Remaining arguments are added here.
.LINK
http://cakebuild.net
https://cakebuild.net
#>
[CmdletBinding()]
Param(
[string]$Script = "build.cake",
[string]$Target = "Default",
[ValidateSet("Release", "Debug")]
[string]$Configuration = "Release",
[string]$Script,
[string]$Target,
[string]$Configuration,
[ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")]
[string]$Verbosity = "Verbose",
[switch]$Experimental,
[Alias("DryRun","Noop")]
[switch]$WhatIf,
[switch]$Mono,
[string]$Verbosity,
[switch]$ShowDescription,
[Alias("WhatIf", "Noop")]
[switch]$DryRun,
[switch]$SkipToolPackageRestore,
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
[string[]]$ScriptArgs
)
# This is an automatic variable in PowerShell Core, but not in Windows PowerShell 5.x
if (-not (Test-Path variable:global:IsCoreCLR)) {
$IsCoreCLR = $false
}
# Attempt to set highest encryption available for SecurityProtocol.
# PowerShell will not set this by default (until maybe .NET 4.6.x). This
# will typically produce a message for PowerShell v2 (just an info
# message though)
try {
# Set TLS 1.2 (3072), then TLS 1.1 (768), then TLS 1.0 (192), finally SSL 3.0 (48)
# Use integers because the enumeration values for TLS 1.2 and TLS 1.1 won't
# exist in .NET 4.0, even though they are addressable if .NET 4.5+ is
# installed (.NET 4.5 is an in-place upgrade).
# PowerShell Core already has support for TLS 1.2 so we can skip this if running in that.
if (-not $IsCoreCLR) {
[System.Net.ServicePointManager]::SecurityProtocol = 3072 -bor 768 -bor 192 -bor 48
}
} catch {
Write-Output 'Unable to set PowerShell to use TLS 1.2 and TLS 1.1 due to old .NET Framework installed. If you see underlying connection closed or trust errors, you may need to upgrade to .NET Framework 4.5+ and PowerShell v3'
}
[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
function MD5HashFile([string] $filePath)
{
@ -80,49 +97,52 @@ function MD5HashFile([string] $filePath)
}
}
function GetProxyEnabledWebClient
{
$wc = New-Object System.Net.WebClient
$proxy = [System.Net.WebRequest]::GetSystemWebProxy()
$proxy.Credentials = [System.Net.CredentialCache]::DefaultCredentials
$wc.Proxy = $proxy
return $wc
}
Write-Host "Preparing to run build script..."
if(!$PSScriptRoot){
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
}
if(!$Script){
$Script = Join-Path $PSScriptRoot "build.cake"
}
$TOOLS_DIR = Join-Path $PSScriptRoot "tools"
$ADDINS_DIR = Join-Path $TOOLS_DIR "Addins"
$MODULES_DIR = Join-Path $TOOLS_DIR "Modules"
$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe"
$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe"
$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config"
$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum"
$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config"
$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config"
# Should we use mono?
$UseMono = "";
if($Mono.IsPresent) {
Write-Verbose -Message "Using the Mono based scripting engine."
$UseMono = "-mono"
}
# Should we use the new Roslyn?
$UseExperimental = "";
if($Experimental.IsPresent -and !($Mono.IsPresent)) {
Write-Verbose -Message "Using experimental version of Roslyn."
$UseExperimental = "-experimental"
}
# Is this a dry run?
$UseDryRun = "";
if($WhatIf.IsPresent) {
$UseDryRun = "-dryrun"
}
$env:CAKE_PATHS_TOOLS = $TOOLS_DIR
$env:CAKE_PATHS_ADDINS = $ADDINS_DIR
$env:CAKE_PATHS_MODULES = $MODULES_DIR
# Make sure tools folder exists
if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) {
Write-Verbose -Message "Creating tools directory..."
New-Item -Path $TOOLS_DIR -Type directory | out-null
New-Item -Path $TOOLS_DIR -Type Directory | Out-Null
}
# Make sure that packages.config exist.
if (!(Test-Path $PACKAGES_CONFIG)) {
Write-Verbose -Message "Downloading packages.config..."
try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch {
try {
$wc = GetProxyEnabledWebClient
$wc.DownloadFile("https://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG)
} catch {
Throw "Could not download packages.config."
}
}
@ -142,14 +162,26 @@ if (!(Test-Path $NUGET_EXE)) {
if (!(Test-Path $NUGET_EXE)) {
Write-Verbose -Message "Downloading NuGet.exe..."
try {
(New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE)
$wc = GetProxyEnabledWebClient
$wc.DownloadFile($NUGET_URL, $NUGET_EXE)
} catch {
Throw "Could not download NuGet.exe."
}
}
# These are automatic variables in PowerShell Core, but not in Windows PowerShell 5.x
if (-not (Test-Path variable:global:ismacos)) {
$IsLinux = $false
$IsMacOS = $false
}
# Save nuget.exe path to environment to be available to child processed
$ENV:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE = $NUGET_EXE
$env:NUGET_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$NUGET_EXE`""
} else {
"`"$NUGET_EXE`""
}
# Restore tools from NuGet?
if(-Not $SkipToolPackageRestore.IsPresent) {
@ -157,24 +189,61 @@ if(-Not $SkipToolPackageRestore.IsPresent) {
Set-Location $TOOLS_DIR
# Check for changes in packages.config and remove installed tools if true.
[string] $md5Hash = MD5HashFile($PACKAGES_CONFIG)
[string] $md5Hash = MD5HashFile $PACKAGES_CONFIG
if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) {
Write-Verbose -Message "Missing or changed package.config hash..."
Remove-Item * -Recurse -Exclude packages.config,nuget.exe
Get-ChildItem -Exclude packages.config,nuget.exe,Cake.Bakery |
Remove-Item -Recurse -Force
}
Write-Verbose -Message "Restoring tools from NuGet..."
$NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`""
if ($LASTEXITCODE -ne 0) {
Throw "An error occured while restoring NuGet tools."
Throw "An error occurred while restoring NuGet tools."
}
else
{
$md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII"
}
Write-Verbose -Message ($NuGetOutput | out-string)
Write-Verbose -Message ($NuGetOutput | Out-String)
Pop-Location
}
# Restore addins from NuGet
if (Test-Path $ADDINS_PACKAGES_CONFIG) {
Push-Location
Set-Location $ADDINS_DIR
Write-Verbose -Message "Restoring addins from NuGet..."
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`""
if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet addins."
}
Write-Verbose -Message ($NuGetOutput | Out-String)
Pop-Location
}
# Restore modules from NuGet
if (Test-Path $MODULES_PACKAGES_CONFIG) {
Push-Location
Set-Location $MODULES_DIR
Write-Verbose -Message "Restoring modules from NuGet..."
$NuGetOutput = Invoke-Expression "& $env:NUGET_EXE_INVOCATION install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`""
if ($LASTEXITCODE -ne 0) {
Throw "An error occurred while restoring NuGet modules."
}
Write-Verbose -Message ($NuGetOutput | Out-String)
Pop-Location
}
@ -183,9 +252,23 @@ if (!(Test-Path $CAKE_EXE)) {
Throw "Could not find Cake.exe at $CAKE_EXE"
}
$CAKE_EXE_INVOCATION = if ($IsLinux -or $IsMacOS) {
"mono `"$CAKE_EXE`""
} else {
"`"$CAKE_EXE`""
}
# Build an array (not a string) of Cake arguments to be joined later
$cakeArguments = @()
if ($Script) { $cakeArguments += "`"$Script`"" }
if ($Target) { $cakeArguments += "--target=`"$Target`"" }
if ($Configuration) { $cakeArguments += "--configuration=$Configuration" }
if ($Verbosity) { $cakeArguments += "--verbosity=$Verbosity" }
if ($ShowDescription) { $cakeArguments += "--showdescription" }
if ($DryRun) { $cakeArguments += "--dryrun" }
$cakeArguments += $ScriptArgs
# Start Cake
Write-Host "Running build script..."
$path = Split-Path -Parent $MyInvocation.MyCommand.Definition
$Script = "$path/build.cake"
Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs"
Invoke-Expression "& $CAKE_EXE_INVOCATION $($cakeArguments -join " ")"
exit $LASTEXITCODE

Просмотреть файл

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.37.0" />
<package id="Cake" version="1.1.0" />
</packages>

Просмотреть файл

@ -1,5 +1,5 @@
{
"msbuild-sdks": {
"MSBuild.Sdk.Extras": "2.0.54"
"MSBuild.Sdk.Extras": "3.0.23"
}
}

Просмотреть файл

@ -1,5 +1,5 @@
{
"version": "2.0.6",
"version": "2.0.7",
"publicReleaseRefSpec": [
"^refs/heads/master$", // we release out of master
"^refs/heads/rel/\\d+\\.\\d+\\.\\d+" // we also release branches starting with rel/N.N.N