Closed kianzarrin closed 3 years ago
TODO:
The CO patch is:
+ Assembly assembly;
+ string symPath = dllPath + ".mdb";
+ if(File.Exists(symPath)) {
+ CODebugBase<InternalLogChannel>.Log(InternalLogChannel.Mods, "Loading " + dllPath + "\nSymbols " + symPath);
+ assembly = Assembly.Load(File.ReadAllBytes(dllPath), File.ReadAllBytes(symPath));
+ } else {
CODebugBase<InternalLogChannel>.Log(InternalLogChannel.Mods, "Loading " + dllPath);
- Assembly assembly = Assembly.Load(File.ReadAllBytes(dllPath));
+ assembly = Assembly.Load(File.ReadAllBytes(dllPath));
+ }
<Target Name="DeployToModDirectory" AfterTargets="Build">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="Targets" />
</GetAssemblyIdentity>
<PropertyGroup>
<DeployDir>$(LOCALAPPDATA)\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)\</DeployDir>
<UnityPath>$(MSBuildExtensionsPath64)\..\Unity\</UnityPath>
<UnityPath Condition="! Exists ('$(UnityPath)')">..\Unity\</UnityPath>
<MonoDir>$(UnityPath)Editor\Data\MonoBleedingEdge\</MonoDir>
</PropertyGroup>
<ItemGroup>
<AuxilaryFiles Include="$(TargetDir)**/*.*" Exclude="$(TargetPath);$(TargetDir)*.pdb" />
<VersionNumber Include="@(Targets->'%(Version)')" />
</ItemGroup>
<Delete Files="$(TargetPath).mdb" />
<Exec Command=""$(MonoDir)bin\mono.exe" "$(MonoDir)lib\mono\4.5\pdb2mdb.exe" "$(TargetPath)"" />
<Copy SourceFiles="$(TargetPath).mdb" DestinationFolder="$(DeployDir)" />
<Copy SourceFiles="@(AuxilaryFiles)" DestinationFolder="$(DeployDir)" />
<!-- <Message Importance="high" Text="Deleting $(DeployDir)$(TargetFileName)" /> -->
<Delete Files="$(DeployDir)$(TargetFileName)" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(DeployDir)" />
<Message Importance="high" Text="AssemblyVersion= @(VersionNumber)" />
</Target>
mkdir "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)"
del "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)"\$(TargetFileName)"
xcopy /y "$(TargetPath)" "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)"
xcopy /y "$(TargetDir)MoveItIntegration.dll" "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)"
set "UNITY_PATH=$(MSBuildExtensionsPath64)\..\Unity"
IF not EXIST "%UNITY_PATH% " set "UNITY_PATH=$(SolutionDir)Unity"
set "MONODIR=%UNITY_PATH%\Editor\Data\MonoBleedingEdge\"
echo MONODIR is %MONODIR%
"%MONODIR%\bin\mono.exe" "%MONODIR%\lib\mono\4.5\pdb2mdb.exe" "$(TargetPath)"
IF EXIST "$(TargetPath).mdb" xcopy /y "$(TargetPath).mdb" "%LOCALAPPDATA%\Colossal Order\Cities_Skylines\Addons\Mods\$(ProjectName)"
krzychu gave me a new mono.dll that is malware free. I updated my LOM tool.
[moved to wiki]
when debugging CS mods it would be useful to get file and line number in your exceptions stack trace like this:
Follow these steps to get file and line number (I am working to reduce these steps).
Use Nuget Package"Mono.Unofficial.pdb2mdb" to generate MDB file:
mono cannot use pdb files. So we need to convert it to mdb file. Not every version of pdb2mdb.exe works for us. So follow these steps to convert pdb to mdb
use the following Nuget package:
generate pdb-only debug symbols ( optionally use the path map to display relative path instead of absolute path):
convert pdb2mdb in your post build script:
Use LOM mod:
Load order tool V0.4.4+ ( github steam ) is able to launch the game in debug mode (uses debug mono and patches CO to load symbols).