Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build.yml #107

Merged
merged 5 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,28 @@ jobs:
with:
dotnet-version: 8.0.x

- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v2

- name: Build win-x64
run: dotnet publish WinForms\WinForms.csproj /p:Configuration=Release /p:Platform=x64 /p:SelfContained=true /p:PublishSingleFile=true /p:PublishReadyToRun=true /p:TargetFramework=net8.0-windows /p:RuntimeIdentifier=win-x64 /p:PublishDir=publish
run: Build_win-x64.bat
shell: cmd

- name: Upload win-x64
uses: actions/upload-artifact@v4
with:
name: Drill_win-x64
path: WinForms\publish
path: bin\Drill_win-x64.exe
if-no-files-found: error


- name: Create a Release
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: true
title: "Development Build"
files: bin\Drill_win-x64.exe


#- name: Build MAUI
# run: dotnet publish --maxCpuCount -f net8.0-windows10.0.19041.0 -c Release -p:RuntimeIdentifierOverride=win10-x64 -p:WindowsPackageType=None .\Drill\Drill.csproj

Expand Down
28 changes: 28 additions & 0 deletions Build_win-x64.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@echo off

dotnet clean -maxCpuCount WinForms\WinForms.csproj
if %ERRORLEVEL% neq 0 (
echo Cleaning failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

dotnet publish -maxCpuCount WinForms\WinForms.csproj /p:DebugType=None /p:DebugSymbols=False /p:Configuration=Release /p:Platform=x64 /p:EnableCompressionInSingleFile=true /p:CopyOutputSymbolsToPublishDirectory=false /p:IncludeNativeLibrariesForSelfExtract=true /p:PublishTrimmed=false /p:SelfContained=true /p:PublishSingleFile=true /p:PublishReadyToRun=true /p:TargetFramework=net8.0-windows /p:RuntimeIdentifier=win-x64 /p:PublishDir=%CD%\bin
if %ERRORLEVEL% neq 0 (
echo Publishing failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

move bin\Drill.exe bin\Drill_win-x64.exe
if %ERRORLEVEL% neq 0 (
echo Moving file failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

dir bin\Drill_win-x64.exe
if %ERRORLEVEL% neq 0 (
echo Directory listing failed with error code %ERRORLEVEL%.
exit /b %ERRORLEVEL%
)

echo Script completed successfully.
exit /b 0
4 changes: 3 additions & 1 deletion Core/Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
<Nullable>enable</Nullable>
</PropertyGroup>



<ItemGroup>
<None Remove="words_alpha.txt" />
<EmbeddedResource Include="words_alpha.txt" />
</ItemGroup>

<ItemGroup>
Expand Down
21 changes: 12 additions & 9 deletions Core/Heuristics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,24 @@

static Heuristics()
{
string? path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (path == null)
var assembly = Assembly.GetExecutingAssembly();
var resourceName = assembly.GetManifestResourceNames().FirstOrDefault(name => name.EndsWith("words_alpha.txt"));

if (resourceName == null)
{
Console.WriteLine("Executing assembly path is null???");
Console.WriteLine("Can't find words dictionary in embedded resources");
dict = [];
return;
}
var DictPath = Path.Combine(path, "words_alpha.txt");
if (!File.Exists(DictPath))

using var stream = assembly.GetManifestResourceStream(resourceName);
if (stream != null)
{
Console.WriteLine("Can't find words dictionary");
dict = [];
return;
using var reader = new StreamReader(stream);
dict = reader.ReadToEnd().Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries).ToImmutableHashSet<string>();
}
dict = [.. File.ReadAllLines(DictPath)];

dict = [];
}


Expand Down Expand Up @@ -106,7 +109,7 @@
// If folder contains the username it's generally very important
|| sub.Name.ToLower().Contains(UserName.ToLower())
// If folder is inside a folder with the username it's generally very important
|| sub.Parent.Name.ToLower().Contains(UserName.ToLower())

Check warning on line 112 in Core/Heuristics.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
)
{
return HeuristicsDirectoryPriority.UsedByAHuman;
Expand Down
Loading