Skip to content

Commit 92243a9

Browse files
committed
build: upgrade to .NET 10
1 parent fc3f1f4 commit 92243a9

10 files changed

Lines changed: 400 additions & 208 deletions

File tree

.github/workflows/build.yml

Lines changed: 164 additions & 127 deletions
Large diffs are not rendered by default.
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
Set-PSDebug -Strict
66

7-
87
#
98
# Perform a single test.
109
# If a passed "expected" date/time object is $Null, there should be no change.
@@ -40,14 +39,12 @@ function TestRun(
4039
#
4140
# Perform the TouchMax operation
4241
#
43-
# .\publish\TouchMax.exe
44-
# .\bin\Release\net6.0\TouchMax.exe
45-
# .\bin\Debug\net6.0\TouchMax.exe
46-
if (-not(Test-Path '.\publish\TouchMax.exe'))
42+
$exists = [bool](Get-Command TouchMax.exe -ErrorAction SilentlyContinue)
43+
if (!$exists)
4744
{
4845
throw 'Executable does not exist.'
4946
}
50-
.\publish\TouchMax.exe $argsOperation.Split() $fn
47+
TouchMax.exe $argsOperation.Split() $fn
5148

5249
#
5350
# Test the expected timestamps
@@ -152,5 +149,5 @@ TestRun "Set Modified to Now -4 years, +3 days, -26 minutes" $dtCreation $dtModi
152149

153150

154151
#TestRun $dtCreation $dtModified "/setfiles /setmodified /Y= /M= /D= /h= /m=" $dtExpectedCreation $dtExpectedModified
155-
# .\bin\Debug\net5.0\TouchMax.exe /setfiles /setcreation ("/Y={0}" -f $dtExpectedCreation.Year) ("/M={0}" -f $dtExpectedCreation.Month) ("/D={0}" -f $dtExpectedCreation.Day) ("/h={0}" -f $dtExpectedCreation.Hour) ("/m={0}" -f $dtExpectedCreation.Minute) $fn
152+
# TouchMax.exe /setfiles /setcreation ("/Y={0}" -f $dtExpectedCreation.Year) ("/M={0}" -f $dtExpectedCreation.Month) ("/D={0}" -f $dtExpectedCreation.Day) ("/h={0}" -f $dtExpectedCreation.Hour) ("/m={0}" -f $dtExpectedCreation.Minute) $fn
156153
#"/setfiles /setmodified /Y=2006 /M=4 /D=30 /h=15 /m=9"

TouchMax.csproj

Lines changed: 0 additions & 28 deletions
This file was deleted.

TouchMax.sln

Lines changed: 0 additions & 36 deletions
This file was deleted.

TouchMax.slnx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Solution>
2+
<Configurations>
3+
<Platform Name="x64" />
4+
</Configurations>
5+
<Folder Name="/Solution Items/">
6+
<File Path=".github/workflows/build.yml" />
7+
<File Path="devtools/BuildMsStore.cmd" />
8+
<File Path="Directory.Build.props" />
9+
<File Path="TestTouchMax.ps1" />
10+
</Folder>
11+
<Project Path="TouchMax/TouchMax.csproj">
12+
<Platform Project="x64" />
13+
</Project>
14+
</Solution>

Program.cs renamed to TouchMax/Program.cs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,35 @@
11
using System;
2+
using System.CommandLine;
3+
using System.CommandLine.Help;
4+
using System.CommandLine.Invocation;
25
using System.IO;
36
using System.Linq;
47

58
namespace TouchMax;
69

7-
/*
8-
* Usage:
9-
* TouchMax +/-HH:MM <file specification>
10-
*
11-
* Pass a file path (with optional wildcards) and the offset to use to
12-
* change the file's last-modified time.
13-
*/
14-
class Program
10+
internal class CustomHelpAction(HelpAction _defaultAction) : SynchronousCommandLineAction
11+
{
12+
public override int Invoke(ParseResult parseResult)
13+
{
14+
parseResult.InvocationConfiguration.Output.Write("header");
15+
16+
int result = _defaultAction.Invoke(parseResult);
17+
18+
//parseResult.InvocationConfiguration.Output.WriteLine("FOOTER");
19+
20+
return result;
21+
22+
}
23+
}
24+
25+
/// <summary>
26+
/// Pass a file path (with optional wildcards) and the offset to use to
27+
/// change the file's last-modified time.
28+
/// </summary>
29+
/// <example>
30+
/// TouchMax.exe +/-HH:MM <file specification>
31+
/// </example>
32+
public class Program
1533
{
1634
private bool _bTest = false;
1735

@@ -356,7 +374,7 @@ private void ParseArguments(string[] args)
356374
{
357375
try
358376
{
359-
if (a.StartsWith("-") || a.StartsWith("/"))
377+
if (a.StartsWith('-') || a.StartsWith('/'))
360378
{
361379
string key = a[1..].ToLower();
362380
if (key.StartsWith("test"))

Properties/PublishProfiles/FolderProfile.pubxml renamed to TouchMax/Properties/PublishProfiles/FolderProfile.pubxml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
88
<Platform>x64</Platform>
99
<PublishDir>C:\VSIntermediate\TouchMax\publish\</PublishDir>
1010
<PublishProtocol>FileSystem</PublishProtocol>
11-
<TargetFramework>net9.0-windows</TargetFramework>
11+
<TargetFramework>net10.0-windows</TargetFramework>
1212
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
1313
<SelfContained>true</SelfContained>
1414
<PublishSingleFile>true</PublishSingleFile>

TouchMax/TouchMax.csproj

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net10.0-windows</TargetFramework>
6+
<Platforms>x64</Platforms>
7+
<PlatformTarget>x64</PlatformTarget>
8+
<Nullable>enable</Nullable>
9+
10+
<PackageId>TouchMax</PackageId>
11+
<PackageProjectUrl>https://12noon.com</PackageProjectUrl>
12+
13+
<SignAssembly>true</SignAssembly>
14+
<AssemblyOriginatorKeyFile>StrongNameKeyFile.snk</AssemblyOriginatorKeyFile>
15+
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="System.CommandLine" Version="2.0.8" />
20+
</ItemGroup>
21+
22+
</Project>

devtools/BuildMsStore.cmd

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
@echo off
2+
rem
3+
rem Perform a clean restore and build.
4+
rem Run all unit tests.
5+
rem Publish a standalone application.
6+
rem Create an app bundle for the Microsoft Store.
7+
rem
8+
9+
setlocal EnableExtensions EnableDelayedExpansion
10+
11+
if NOT EXIST "TouchMax.slnx" (
12+
echo Run this script from the solution folder.
13+
goto :EOF
14+
)
15+
16+
echo.
17+
echo To avoid errors on locked files and folders, such as PackageLayout, etc.:
18+
echo - Pause Onedrive
19+
echo - Exit Visual Studio
20+
echo.
21+
echo Update the version in:
22+
echo - Directory.Build.props
23+
24+
set PROJECT=TouchMax
25+
set ARCHIVE_NAME=%PROJECT%
26+
set BUILD_OUTPUT_ROOT=C:\VSIntermediate\%PROJECT%
27+
set ARTIFACTS_PATH=%BUILD_OUTPUT_ROOT%\artifacts
28+
set PUBLISH_FILES_PATH=%BUILD_OUTPUT_ROOT%\publish
29+
set DIRECTORY_BUILD_PROPS=.\Directory.Build.props
30+
set PROJECT_APP_PATH=.\%PROJECT%\%PROJECT%.csproj
31+
set TARGET_EXE_PATH=%ARTIFACTS_PATH%\bin\%PROJECT%\release\%PROJECT%.exe
32+
set FOLDER_TESTS_PATH=.\Tests
33+
set SCRIPT_TESTS_PATH=.\TestTouchMax.ps1
34+
35+
::
36+
:: PRE-BUILD CHECKS
37+
::
38+
39+
echo.
40+
echo === COMPARE VERSIONS IN Directory.Build.props ===
41+
echo.
42+
43+
rem === 1. Locate the Directory.Build.props file ===
44+
if not exist "%DIRECTORY_BUILD_PROPS%" (
45+
echo ERROR: Version file not found: %DIRECTORY_BUILD_PROPS%
46+
exit /b 1
47+
)
48+
49+
rem === 2. Extract VersionPrefix from Directory.Build.props ===
50+
for /f "usebackq delims=" %%V in (`
51+
powershell -NoLogo -NoProfile -Command ^
52+
"[xml]$x = Get-Content '%DIRECTORY_BUILD_PROPS%'; $x.Project.PropertyGroup.VersionPrefix"
53+
`) do set "VERSION_PREFIX=%%V"
54+
55+
if "%VERSION_PREFIX%" == "" (
56+
echo ERROR: VersionPrefix not found in %DIRECTORY_BUILD_PROPS%
57+
exit /b 1
58+
)
59+
60+
echo Version: %VERSION_PREFIX%
61+
62+
set VERSION=%VERSION_PREFIX%
63+
64+
echo.
65+
choice /c YN /n /m "Press N to quit, Y to continue: "
66+
if errorlevel 2 (
67+
echo Quitting...
68+
exit /b 0
69+
)
70+
71+
::
72+
:: BUILD
73+
::
74+
75+
echo.
76+
echo === DOTNET CLEAN ===
77+
dotnet clean "%PROJECT_APP_PATH%"
78+
if errorlevel 1 exit /b %ERRORLEVEL%
79+
REM dotnet clean "%PROJECT_TESTS_PATH%"
80+
REM if errorlevel 1 exit /b %ERRORLEVEL%
81+
82+
echo.
83+
echo === DOTNET RESTORE ===
84+
dotnet restore "%PROJECT_APP_PATH%" --runtime win-x64
85+
if errorlevel 1 exit /b %ERRORLEVEL%
86+
REM dotnet restore "%PROJECT_TESTS_PATH%"
87+
REM if errorlevel 1 exit /b %ERRORLEVEL%
88+
89+
echo.
90+
echo === DOTNET BUILD RELEASE ===
91+
dotnet build ^
92+
"%PROJECT_APP_PATH%" ^
93+
--configuration Release ^
94+
--no-restore
95+
96+
if errorlevel 1 exit /b %ERRORLEVEL%
97+
98+
echo.
99+
echo === VERIFY TARGET PROPERTIES ===
100+
if exist "%TARGET_EXE_PATH%" (
101+
sigcheck.exe -nobanner "%TARGET_EXE_PATH%"
102+
) else (
103+
echo File does not exist: "%TARGET_EXE_PATH%"
104+
exit /b
105+
)
106+
107+
::
108+
:: TESTS
109+
::
110+
111+
echo.
112+
echo === DOTNET BUILD UNIT TESTS ===
113+
REM dotnet build ^
114+
REM "%PROJECT_TESTS_PATH%" ^
115+
REM --configuration Release ^
116+
REM --no-restore
117+
118+
REM if errorlevel 1 exit /b %ERRORLEVEL%
119+
120+
echo.
121+
echo === DOTNET TEST ===
122+
REM dotnet test ^
123+
REM --project "%PROJECT_TESTS_PATH%" ^
124+
REM --configuration Release ^
125+
REM --no-restore ^
126+
REM --no-build ^
127+
REM --no-ansi ^
128+
REM --no-progress ^
129+
REM --output detailed
130+
131+
REM if errorlevel 1 exit /b %ERRORLEVEL%
132+
133+
setlocal
134+
for %%I in ("%TARGET_EXE_PATH%") do set "EXEDIR=%%~dpI"
135+
set PATH=%EXEDIR%;%PATH%
136+
powershell -NoLogo -NoProfile -Command ^
137+
"Set-Location '%FOLDER_TESTS_PATH%' ; %SCRIPT_TESTS_PATH%"
138+
endlocal
139+
140+
::
141+
:: PUBLISH
142+
::
143+
144+
echo.
145+
echo === DOTNET PUBLISH (Standalone) ===
146+
dotnet publish ^
147+
"%PROJECT_APP_PATH%" ^
148+
--configuration Release ^
149+
--framework=net10.0-windows ^
150+
--no-restore ^
151+
--property:Platform=x64 ^
152+
--property:RuntimeIdentifier=win-x64 ^
153+
--property:PublishProtocol=FileSystem ^
154+
--property:SelfContained=true ^
155+
--property:PublishReadyToRun=false ^
156+
--property:PublishTrimmed=false ^
157+
--property:PublishSingleFile=true ^
158+
--property:PublishDir="%PUBLISH_FILES_PATH%"
159+
160+
if errorlevel 1 exit /b %ERRORLEVEL%
161+
162+
pushd "%PUBLISH_FILES_PATH%"
163+
nanazipc.exe u -tzip "%BUILD_OUTPUT_ROOT%\%ARCHIVE_NAME%_%VERSION%.zip" *.*
164+
popd
165+
166+
echo Publish successful.
167+
168+
endlocal

0 commit comments

Comments
 (0)