Skip to content

Commit

Permalink
working through installer
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeeOgre committed Aug 28, 2024
1 parent 56b2df8 commit 6091ae7
Show file tree
Hide file tree
Showing 52 changed files with 371 additions and 3,256 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/build-and-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
strategy:
matrix:
configuration: [Debug, Release]
configuration: [Debug, Release, GithubRelease] # Added GithubRelease to the matrix

runs-on: windows-latest

Expand All @@ -35,12 +35,14 @@ jobs:
uses: microsoft/setup-msbuild@v2

- name: Increment version number
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
id: increment_version
run: |
.\scripts\increment-version.ps1 -filePath ${{ env.Wap_Project_Path }} -solutionDir . -branch master # Updated to master
.\scripts\increment-version.ps1 -filePath ${{ env.Wap_Project_Path }} -solutionDir . -branch master -msiFilePath ${{ env.Wap_Project_Directory }}\Release\DevModManagerInstaller.msi # Updated to master
shell: pwsh

- name: Commit new version
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
Expand Down Expand Up @@ -80,19 +82,22 @@ jobs:
path: ${{ env.Wap_Project_Directory }}\Release\DevModManagerInstaller.msi

- name: Create source zip
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
run: |
$version = "${{ steps.increment_version.outputs.newVersion }}"
$zipPath = "DevModManager.src.$version.zip"
Compress-Archive -Path * -DestinationPath $zipPath -Force -Exclude **\bin\*, **\obj\*
shell: pwsh

- name: Upload source zip
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
uses: actions/upload-artifact@v3
with:
name: Source Code
path: DevModManager.src.${{ steps.increment_version.outputs.newVersion }}.zip

- name: Create GitHub Release
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
id: create_release
uses: actions/create-release@v1
env:
Expand All @@ -102,8 +107,10 @@ jobs:
release_name: Release ${{ steps.increment_version.outputs.newVersion }}
draft: false
prerelease: false
make_latest: true # Mark the release as the latest

- name: Upload MSI to Release
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -114,6 +121,7 @@ jobs:
asset_content_type: application/octet-stream

- name: Upload Source Zip to Release
if: matrix.configuration == 'GithubRelease' # Only run for GithubRelease configuration
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
8 changes: 0 additions & 8 deletions App.config

This file was deleted.

1 change: 0 additions & 1 deletion App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@
<Application.Resources>
<!-- Application resource dictionary -->
</Application.Resources>

</Application>
48 changes: 24 additions & 24 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.Loader;
using System.Windows;

namespace DevModManager
Expand All @@ -11,10 +12,13 @@ namespace DevModManager
/// </summary>
public partial class App : Application
{
/// <summary>
/// Initializes a new instance of the <see cref="App"/> class.
/// </summary>
public App()
{
// Temporarily remove AssemblyResolve logic
// AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
// Set up the assembly resolving event handler
AssemblyLoadContext.Default.Resolving += OnAssemblyResolve;
}

private void Application_Startup(object sender, StartupEventArgs e)
Expand Down Expand Up @@ -48,7 +52,7 @@ private void Application_Startup(object sender, StartupEventArgs e)
}
}

private void SettingsWindow_Closed(object sender, EventArgs e)
private void SettingsWindow_Closed(object? sender, EventArgs e)
{
Debug.WriteLine("SettingsWindow_Closed called");

Expand All @@ -57,14 +61,14 @@ private void SettingsWindow_Closed(object sender, EventArgs e)
// Check again if the database is initialized after settings window is closed
if (DbManager.Instance.IsDatabaseInitialized())
{
// Open MainWindow if the database is now initialized
// Open MainWindow if the database is initialized
var mainWindow = new MainWindow();
mainWindow.Show();
}
else
{
// Shutdown the application if the database is still not initialized
Shutdown();
// Handle the case where the database is still not initialized
MessageBox.Show("Database initialization failed. Please check your settings.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
catch (Exception ex)
Expand All @@ -74,34 +78,30 @@ private void SettingsWindow_Closed(object sender, EventArgs e)
}
}

// Temporarily remove OnResolveAssembly method
/*
private Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
private static Assembly? OnAssemblyResolve(AssemblyLoadContext context, AssemblyName assemblyName)
{
string assemblyName = new AssemblyName(args.Name).Name + ".dll";
string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
// Get the probing paths from the environment variable
string? probingPaths = Environment.GetEnvironmentVariable("PROBING_PATHS");

// Check in lib directory
string libPath = Path.Combine(baseDirectory, "lib", assemblyName);
if (File.Exists(libPath))
if (!string.IsNullOrEmpty(probingPaths))
{
return Assembly.LoadFrom(libPath);
}
// Split the paths by the path separator
string[] paths = probingPaths.Split(';');

// Check in locale subdirectories
string[] localeDirectories = Directory.GetDirectories(Path.Combine(baseDirectory, "locale"), "*", SearchOption.AllDirectories);
foreach (var dir in localeDirectories)
{
string localePath = Path.Combine(dir, assemblyName);
if (File.Exists(localePath))
foreach (string path in paths)
{
return Assembly.LoadFrom(localePath);
// Construct the path to the assembly
string assemblyPath = Path.Combine(AppContext.BaseDirectory, path, $"{assemblyName.Name}.dll");

if (File.Exists(assemblyPath))
{
return context.LoadFromAssemblyPath(assemblyPath);
}
}
}

return null;
}
*/
}

}
138 changes: 127 additions & 11 deletions DevModManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,19 @@
<RepositoryUrl>https://github.com/ZeeOgre/DevModManager</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
<Version>0.0.1</Version> <!-- Initial version set to 0.0.1 -->
<Version>0.0.1</Version>
<Configurations>Debug;Release;GitRelease</Configurations>
</PropertyGroup>


<!--
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="if not exist $(InstallerDir) mkdir $(InstallerDir)" />
</Target> -->

<ItemGroup>
<Content Include="docs\img\ZeeOgre.ico" />
<Content Include="docs\img\ZeeOgre_NoBackground.jpg"> <!-- Ensure the file is included -->
<Content Include="docs\img\ZeeOgre_NoBackground.jpg">
<!-- Ensure the file is included -->
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</Content>
Expand All @@ -33,7 +40,7 @@
<ItemGroup>
<PackageReference Include="Autoupdater.NET.Official" Version="1.9.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="SharpCompress" Version="0.37.2" />
<PackageReference Include="System.Data.SQLite" Version="1.0.118" />
Expand All @@ -57,12 +64,13 @@
</None>
</ItemGroup>

<!-- Release Configuration -->
<ItemGroup Condition="'$(Configuration)' == 'Release'">
<!-- Release and GitRelease Configuration -->
<ItemGroup Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'GitRelease'">
<None Update="data\DevModManager.db">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<None Update="docs\img\ZeeOgre_NoBackground.jpg">
<Pack>True</Pack>
Expand All @@ -74,15 +82,123 @@
</None>
</ItemGroup>

<!-- Rename config_sample.yaml to config.yaml in Release build -->
<Target Name="RenameConfigFile" Condition="'$(Configuration)' == 'Release'" AfterTargets="AfterBuild">
<!-- Rename config_sample.yaml to config.yaml in Release and GitRelease builds -->
<Target Name="RenameConfigFile" Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'GitRelease'" AfterTargets="AfterBuild">
<MakeDir Directories="$(OutputPath)config" />
<Copy SourceFiles="config\config_sample.yaml" DestinationFiles="$(OutputPath)config\config.yaml" />
</Target>

<!-- PostBuild Target to Update Version and Tag -->
<Target Name="PostBuild" Condition="'$(Configuration)' == 'Release'" AfterTargets="Build">
<!-- Move language resource files to locale subfolder -->
<Target Name="MoveLanguageResources" AfterTargets="Build">
<ItemGroup>
<LanguageResources Include="$(OutputPath)**\*.resources.dll" />
</ItemGroup>
<Message Text="Moving language resource files to locale subfolder..." Importance="high" />
<Move SourceFiles="@(LanguageResources)" DestinationFolder="$(OutputPath)locale\%(RecursiveDir)" />
<RemoveDir Directories="@(LanguageResources->'%(RootDir)%(Directory)')" Condition="!Exists('%(RootDir)%(Directory)%(Filename)%(Extension)')" />
</Target>

<!-- Move DLL files to lib subfolder -->
<Target Name="MoveDllFiles" AfterTargets="MoveLanguageResources">
<ItemGroup>
<DllFiles Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(AssemblyName).dll" />
</ItemGroup>
<Message Text="Moving DLL files to lib subfolder..." Importance="high" />
<Move SourceFiles="@(DllFiles)" DestinationFolder="$(OutputPath)lib\" />
</Target>

<!-- Add runtime configuration option for probing subdirectories -->
<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.DefaultProbingPaths" Value="lib;locale" />
</ItemGroup>

<PropertyGroup>
<ProbingPaths>lib;locale</ProbingPaths>
</PropertyGroup>

<Target Name="SetProbingPaths" BeforeTargets="Build">
<Exec Command="setx PROBING_PATHS $(ProbingPaths)" />
</Target>

<!-- PostBuild Target to Update Version and Tag
<Target Name="PostBuild" Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'GitRelease'" AfterTargets="Build">
<Exec Command="powershell -File &quot;$(SolutionDir)scripts\increment-version.ps1&quot; -filePath &quot;$(SolutionDir)InstallAware\DevModManager_Any CPU.iaext.prjconf&quot; -solutionDir &quot;$(SolutionDir)&quot; -branch main" />
</Target>
</Project>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="powershell -ExecutionPolicy Bypass -File $(SolutionDir)scripts\increment-version.ps1 -filePath $(SolutionDir)InstallAware\DevModManager_Any CPU.iaext.prjconf -solutionDir $(SolutionDir) -branch master -msiFilePath $(InstallerDir)DevModManager.msi -configuration $(Configuration) -outputPath $(OutputPath) -jsonConfigPath $(SolutionDir)installer\DevModManager_mpdev.json" />
<Exec Command="powershell -ExecutionPolicy Bypass -File $(SolutionDir)scripts\create-msi.ps1 -configuration $(Configuration) -outputPath $(OutputPath) -installerDir $(InstallerDir) -jsonConfigPath $(SolutionDir)installer\DevModManager_mpdev.json" />
<Exec Command="powershell -ExecutionPolicy Bypass -File $(SolutionDir)scripts\build-mpdev-json.ps1 -outputDirectory $(OutputPath) -jsonConfigPath $(SolutionDir)installer\DevModManager_mpdev.json" />
</Target> -->

<ItemGroup>
<RuntimeHostConfigurationOption Include="System.Runtime.Loader.DefaultProbingPaths" Value="$(ProbingPaths)" />
</ItemGroup>




<!-- Other ItemGroups and Targets -->

<Target Name="EchoPaths" AfterTargets="Build">
<WriteLinesToFile
File="$(OutputPath)paths.txt"
Lines="
SolutionDir $(SolutionDir)
ProjectDir $(ProjectDir)
OutputPath $(OutputPath)
OutDir $(OutDir)
TargetDir $(TargetDir)
BaseIntermediateOutputPath $(BaseIntermediateOutputPath)
IntermediateOutputPath $(IntermediateOutputPath)
MSBuildProjectDirectory $(MSBuildProjectDirectory)
MSBuildThisFileDirectory $(MSBuildThisFileDirectory)
MSBuildExtensionsPath $(MSBuildExtensionsPath)
MSBuildExtensionsPath32 $(MSBuildExtensionsPath32)
MSBuildExtensionsPath64 $(MSBuildExtensionsPath64)
MSBuildUserExtensionsPath $(MSBuildUserExtensionsPath)
MSBuildStartupDirectory $(MSBuildStartupDirectory)
MSBuildProgramFiles32 $(MSBuildProgramFiles32)
MSBuildProgramFiles64 $(MSBuildProgramFiles64)
MSBuildProjectFile $(MSBuildProjectFile)
MSBuildProjectFullPath $(MSBuildProjectFullPath)
MSBuildProjectName $(MSBuildProjectName)
MSBuildProjectExtension $(MSBuildProjectExtension)
MSBuildThisFile $(MSBuildThisFile)
MSBuildThisFileFullPath $(MSBuildThisFileFullPath)
MSBuildThisFileName $(MSBuildThisFileName)
MSBuildThisFileExtension $(MSBuildThisFileExtension)
MSBuildBinPath $(MSBuildBinPath)
MSBuildToolsPath $(MSBuildToolsPath)
MSBuildToolsVersion $(MSBuildToolsVersion)
BuildingInsideVisualStudio $(BuildingInsideVisualStudio)
BuildingProject $(BuildingProject)
DevEnvDir $(DevEnvDir)
MSBuildLastTaskResult $(MSBuildLastTaskResult)
MSBuildNodeCount $(MSBuildNodeCount)
MSBuildStartupDirectory $(MSBuildStartupDirectory)
MSBuildUserExtensionsPath $(MSBuildUserExtensionsPath)
MSBuildVersion $(MSBuildVersion)
VisualStudioDir $(VisualStudioDir)
VisualStudioEdition $(VisualStudioEdition)
VisualStudioVersion $(VisualStudioVersion)
Configuration $(Configuration)
Platform $(Platform)
ProjectName $(ProjectName)
ProjectPath $(ProjectPath)
TargetName $(TargetName)
TargetExt $(TargetExt)
TargetFileName $(TargetFileName)
TargetPath $(TargetPath)
IntDir $(IntDir)
OutDir $(OutDir)
SolutionName $(SolutionName)
SolutionPath $(SolutionPath)
SolutionDir $(SolutionDir)
SolutionFileName $(SolutionFileName)
SolutionExt $(SolutionExt)
TargetFramework $(TargetFramework)"
Overwrite="true" />
</Target>

</Project>
Loading

0 comments on commit 6091ae7

Please sign in to comment.