Skip to content

Commit

Permalink
Merge pull request #16 from psyGamer/main
Browse files Browse the repository at this point in the history
  • Loading branch information
swoolcock authored Mar 6, 2024
2 parents 28cf2a0 + ac17f5f commit a92f4f5
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 14 deletions.
3 changes: 1 addition & 2 deletions CelesteMod/.github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ jobs:
name: CelesteMod
path: |
everest.yaml
bin/CelesteMod.dll
bin/CelesteMod.pdb
bin
#if Samples
Ahorn/**/*
Audio/**/*
Expand Down
3 changes: 3 additions & 0 deletions CelesteMod/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Packaged mods
CelesteMod.zip

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
Expand Down
83 changes: 73 additions & 10 deletions CelesteMod/Source/CelesteMod-core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,93 @@
</ItemDefinitionGroup>

<ItemGroup>
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" />
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.0.2" PrivateAssets="all" ExcludeAssets="runtime" />
<PackageReference Include="MonoMod.Patcher" Version="25.0.0-prerelease.2" />
<PackageReference Include="CelesteAnalyzer" Version="1.0.3.1" />
</ItemGroup>

<ItemGroup>
<Reference Include="$(CelestePrefix)\Celeste.dll">
<Private>false</Private>
</Reference>
<Reference Include="$(CelestePrefix)\MMHOOK_Celeste.dll">
<Private>false</Private>
</Reference>
<Reference Include="$(CelestePrefix)\FNA.dll">
<Private>false</Private>
</Reference>
<!--/-:replacements:noEmit -->
<PackageReference Include="CelesteMod.Publicizer" Version="*" CelesteAssembly="$(CelestePrefix)\Celeste.dll" />
<!--/+:replacements:noEmit -->
<Reference Include="$(CelestePrefix)\MMHOOK_Celeste.dll" Private="false" />
<Reference Include="$(CelestePrefix)\FNA.dll" Private="false" />
</ItemGroup>

<Target Name="CopyFiles" AfterTargets="Build">
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).dll" DestinationFolder="..\bin" />
<Copy SourceFiles="$(OutputPath)\$(AssemblyName).pdb" DestinationFolder="..\bin" />
</Target>

<Target Name="PackageMod" AfterTargets="CopyFiles" Condition="'$(Configuration)' == 'Release'">
<ItemGroup>
<FilesToPackage Include="..\everest.yaml" />
<FilesToPackage Include="..\bin\**\*.*" />
<FilesToPackage Include="..\Audio\**\*.*" />
<FilesToPackage Include="..\Dialog\**\*.*" />
<FilesToPackage Include="..\Graphics\**\*.*" />
<FilesToPackage Include="..\Ahorn\**\*.*" />
<FilesToPackage Include="..\Loenn\**\*.*" />
</ItemGroup>
<PackageMod Files="@(FilesToPackage)" OutputPath="..\CelesteMod.zip" />
</Target>

<PropertyGroup>
<PathMap>$(MSBuildProjectDirectory)=CelesteMod/</PathMap>
</PropertyGroup>

<!-- Inline task used to create a .zip for the mod -->
<UsingTask TaskName="PackageMod"
TaskFactory="RoslynCodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<OutputPath ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var projectDir = Path.Combine("$(ProjectDir)", ".."); // Go one level up, since we're inside the 'Source' directory
if (File.Exists(OutputPath))
File.Delete(OutputPath);
using (ZipArchive zip = ZipFile.Open(OutputPath, ZipArchiveMode.Create))
{
foreach (var file in Files)
{
string filePath = file.GetMetadata("FullPath");
string entryName = GetRelativePath(projectDir, filePath);
zip.CreateEntryFromFile(filePath, entryName);
}
}
string GetRelativePath(string fromPath, string toPath)
{
if (string.IsNullOrEmpty(fromPath)) throw new ArgumentNullException(nameof(fromPath));
if (string.IsNullOrEmpty(toPath)) throw new ArgumentNullException(nameof(toPath));
Uri fromUri = new Uri(fromPath);
Uri toUri = new Uri(toPath);
if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
Uri relativeUri = fromUri.MakeRelativeUri(toUri);
string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
if (toUri.Scheme.Equals("file", StringComparison.InvariantCultureIgnoreCase))
{
relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
}
return relativePath;
}
]]>
</Code>
</Task>
</UsingTask>

</Project>
2 changes: 1 addition & 1 deletion CelesteMod/everest-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
DLL: bin/CelesteMod.dll
Dependencies:
- Name: EverestCore
Version: 1.4465.0
Version: 1.4607.0
2 changes: 1 addition & 1 deletion CelesteMod/everest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
DLL: bin/CelesteMod.dll
Dependencies:
- Name: Everest
Version: 1.3471.0
Version: 1.4449.0

0 comments on commit a92f4f5

Please sign in to comment.