Skip to content

Commit

Permalink
Merge pull request #42 from thomaslevesque/modernize
Browse files Browse the repository at this point in the history
Drop support for unsupported TFMs and modernize build script
  • Loading branch information
thomaslevesque authored Jan 26, 2024
2 parents 751b2f7 + 8e738fc commit fe5b777
Show file tree
Hide file tree
Showing 15 changed files with 131 additions and 125 deletions.
3 changes: 3 additions & 0 deletions NHotkey.sln
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NHotkey.Wpf.Demo", "samples\NHotkey.Wpf.Demo\NHotkey.Wpf.Demo.csproj", "{338F60F0-F9FE-42AB-9EAE-31E9C3E3CEC3}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{CEE3E414-E343-43C9-8CB9-72CA02FD0299}"
ProjectSection(SolutionItems) = preProject
samples\Directory.Build.props = samples\Directory.Build.props
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{FBA6085F-DD7E-4E18-9BC8-8F709157EC33}"
ProjectSection(SolutionItems) = preProject
Expand Down
5 changes: 5 additions & 0 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<DemoTargetFrameworks>net481;net8.0-windows</DemoTargetFrameworks>
</PropertyGroup>
</Project>
9 changes: 0 additions & 9 deletions samples/NHotkey.WindowsForms.Demo/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 0 additions & 24 deletions samples/NHotkey.WindowsForms.Demo/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -58,28 +58,4 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing.Common" name="System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"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4QICl+4kA5fuhgWW7PMGlev/BpXr6wSY64MNjOkQJ23lTC9j5PwuZOSBAAAAAAAAAAAAAAAAAAAAAAAA
AAAElu0JBpXr1QaV6/8GlevpBpbrfASY6xcAAAAAK2fkNi5k5PgsZuT4LGbkRAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAaV62wGlet+BZbrFQAAAAAAAAAALWTkIi1l5OUsZuT/LGbkWAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALmPkDyxl5MssZuT/LGbkewAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALmPkAixm5K0sZuT/LGbkoQAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAALmTkAixm5JMsZuT/LGbkwCxm5AcAAAAAAAAAAAAA
AAAAAAAAgAEAAIAB8L+f+QAAkAkAAJAJAACfAQAA4AcAAOAHAADggwAA/gEAAPABAADwIQAA+MP///+H
////DwAA/g8AAA==
</value>
</data>
</root>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>$(DemoTargetFrameworks)</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
<OutputType>WinExe</OutputType>
<IsPackable>false</IsPackable>
Expand Down
2 changes: 2 additions & 0 deletions samples/NHotkey.WindowsForms.Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
#if !NETFRAMEWORK
Application.SetHighDpiMode(HighDpiMode.PerMonitorV2);
#endif
Application.Run(new Form1());
}
}
Expand Down
4 changes: 2 additions & 2 deletions samples/NHotkey.Wpf.Demo/NHotkey.Wpf.Demo.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFrameworks>$(DemoTargetFrameworks)</TargetFrameworks>
<UseWPF>true</UseWPF>
<OutputType>WinExe</OutputType>
<IsPackable>false</IsPackable>
Expand All @@ -9,4 +9,4 @@
<ItemGroup>
<ProjectReference Include="..\..\src\NHotkey.Wpf\NHotkey.Wpf.csproj" />
</ItemGroup>
</Project>
</Project>
1 change: 1 addition & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<Project>

<PropertyGroup>
<LibraryTargetFrameworks>net462;net6.0-windows</LibraryTargetFrameworks>
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)NHotkey.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions src/NHotkey.WindowsForms/NHotkey.WindowsForms.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFrameworks>net40;net45;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>$(LibraryTargetFrameworks)</TargetFrameworks>
<UseWindowsForms>true</UseWindowsForms>
</PropertyGroup>
<PropertyGroup Label="Package properties">
Expand All @@ -9,4 +9,4 @@
<ItemGroup>
<ProjectReference Include="..\NHotkey\NHotkey.csproj" />
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions src/NHotkey.Wpf/NHotkey.Wpf.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFrameworks>net40;net45;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>$(LibraryTargetFrameworks)</TargetFrameworks>
<UseWPF>true</UseWPF>
</PropertyGroup>
<PropertyGroup Label="Package properties">
Expand All @@ -9,4 +9,4 @@
<ItemGroup>
<ProjectReference Include="..\NHotkey\NHotkey.csproj" />
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions src/NHotkey/NHotkey.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net40;net45;netcoreapp3.0</TargetFrameworks>
<TargetFrameworks>$(LibraryTargetFrameworks)</TargetFrameworks>
</PropertyGroup>

<PropertyGroup Label="Package properties">
<Description>A managed library to handle global hotkeys in Windows Forms and WPF applications. NOTE: this package doesn't contain a concrete HotkeyManager implementation; you should add either the NHotkey.Wpf or NHotkey.WindowsForms package to get one.</Description>
</PropertyGroup>

</Project>
</Project>
78 changes: 0 additions & 78 deletions tools/build/Build.cs

This file was deleted.

55 changes: 55 additions & 0 deletions tools/build/CommandLineOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
using static Bullseye.Targets;

internal record CommandLineOptions(string Configuration, bool ShowHelp, string[] BullseyeArgs)
{
public static CommandLineOptions Parse(string[] args)
{
var bullseyeArgs = new List<string>();
string configuration = "Release";
bool showHelp = false;
using var enumerator = ((IEnumerable<string>)args).GetEnumerator();
while (enumerator.MoveNext())
{
var arg = enumerator.Current;
if (arg is "-h" or "--help")
{
showHelp = true;
break;
}
else if (arg is "-c" or "--configuration")
{
configuration = ReadOptionValue(arg);
}
else
{
bullseyeArgs.Add(arg);
}
}

return new(configuration, showHelp, bullseyeArgs.ToArray());

string ReadOptionValue(string arg)
{
if (!enumerator.MoveNext())
throw new InvalidOperationException($"Expected value for option '{arg}', but none was found.");

return enumerator.Current;
}
}

public static async Task PrintUsageAsync()
{
Console.WriteLine("Usage:");
Console.WriteLine(" build [-c|--configuration <buildConfiguration>] <bullseyeArgs>");
Console.WriteLine();
Console.WriteLine("Arguments:");
Console.WriteLine(" <bullseyeArguments> Arguments to pass to Bullseye (targets and options, see below)");
Console.WriteLine();
Console.WriteLine("Options:");
Console.WriteLine(" -c, --configuration <buildConfiguration> The configuration to build [default: Release]");
Console.WriteLine(" -? -h, --help Show help and usage information");
Console.WriteLine();
Console.WriteLine("Bullseye help:");
await RunTargetsWithoutExitingAsync(["--help"]);
}
}
52 changes: 52 additions & 0 deletions tools/build/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Runtime.CompilerServices;
using static Bullseye.Targets;
using static SimpleExec.Command;

var commandLineOptions = CommandLineOptions.Parse(args);

Directory.SetCurrentDirectory(GetSolutionDirectory());

string artifactsDir = Path.GetFullPath("artifacts");
string logsDir = Path.Combine(artifactsDir, "logs");
string buildLogFile = Path.Combine(logsDir, "build.binlog");
string packagesDir = Path.Combine(artifactsDir, "packages");

string solutionFile = "NHotkey.sln";

Target(
"artifactDirectories",
() =>
{
Directory.CreateDirectory(artifactsDir);
Directory.CreateDirectory(logsDir);
Directory.CreateDirectory(packagesDir);
});

Target(
"build",
DependsOn("artifactDirectories"),
() => Run(
"dotnet",
$"build -c \"{commandLineOptions.Configuration}\" /bl:\"{buildLogFile}\" \"{solutionFile}\""));

Target(
"pack",
DependsOn("artifactDirectories", "build"),
() => Run(
"dotnet",
$"pack -c \"{commandLineOptions.Configuration}\" --no-build -o \"{packagesDir}\""));

Target("default", DependsOn("pack"));

if (commandLineOptions.ShowHelp)
{
await CommandLineOptions.PrintUsageAsync();
return;
}

await RunTargetsAndExitAsync(commandLineOptions.BullseyeArgs);

static string GetSolutionDirectory() =>
Path.GetFullPath(Path.Combine(GetScriptDirectory(), @"..\.."));

static string GetScriptDirectory([CallerFilePath] string filename = null) => Path.GetDirectoryName(filename);
9 changes: 4 additions & 5 deletions tools/build/build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<IsPackable>false</IsPackable>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Bullseye" Version="3.0.0" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="2.4.2" />
<PackageReference Include="SimpleExec" Version="6.1.0" />
<PackageReference Include="Bullseye" Version="4.2.1" />
<PackageReference Include="SimpleExec" Version="11.0.0" />
</ItemGroup>

</Project>

0 comments on commit fe5b777

Please sign in to comment.