From 4a1a8975a3e3b8de065bc24287d834c659f7ec38 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 01:30:19 -0700 Subject: [PATCH 01/36] Rename properties to avoid namespace collisions, add more toggles --- .github/actions/compile/action.yml | 2 +- KSPBuildTools.csproj | 6 +- KSPCommon.props | 165 +++++++++++------------ KSPCommon.targets | 74 ++++++++-- docs/msbuild/generating-version-files.md | 4 +- docs/msbuild/properties.md | 16 +-- tests/plugin-mod-nuget/plugin-mod.csproj | 11 +- tests/plugin-mod/plugin-mod.csproj | 11 +- 8 files changed, 161 insertions(+), 128 deletions(-) diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index d8c70dc..ab716de 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -76,5 +76,5 @@ runs: working-directory: ${{ inputs.working-directory }} run: | dotnet msbuild -p:Configuration=${{ inputs.build-configuration }} \ - -p:ManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ + -p:KSPManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ ${{ runner.debug && '-v:detailed' }} diff --git a/KSPBuildTools.csproj b/KSPBuildTools.csproj index aa6d9f9..4ebf998 100644 --- a/KSPBuildTools.csproj +++ b/KSPBuildTools.csproj @@ -24,7 +24,7 @@ 1701;1702;CS0649;CS1591;NU5128 2024 KSPModdingLibs Contributors KSPBuildTools - $(ProjectDir) + $(ProjectDir) KSPBuildTools README.md KSP Build Tools @@ -50,4 +50,8 @@ + + + + \ No newline at end of file diff --git a/KSPCommon.props b/KSPCommon.props index f9ce71c..c061bc3 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -4,47 +4,84 @@ true - + - true - - - - - true - true - - - - - 1.12 1.11 1.10 1.9 1.8 + + + true + + + true + + + true + + + + + + true + + + + + true + + + + true + + + + true + + + + + 1.12 1.11 1.10 1.9 1.8 + - - KSP_x64_Data\Managed - KSP.app\Contents\Resources\Data\Managed - KSP_Data\Managed + + + KSP_x64_Data/Managed + + + KSP.app/Contents/Resources/Data/Managed + + + KSP_Data/Managed + + - KSP_x64.exe - KSP.app/Contents/MacOS/KSP - KSP.x86_64 - C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program + KSP_x64.exe + KSP.app/Contents/MacOS/KSP + KSP.x86_64 + + C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program + + + $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program + - - $(SolutionDir.TrimEnd([System.IO.Path]::DirectorySeparatorChar)) - GameData/$(SolutionName) + + + $(ProjectDir)/../GameData/$(ProjectName)/ + + + $(KSPModGameData)/Plugins/ + - @@ -55,16 +92,16 @@ + - - $(ManagedRelativePath)/Assembly-CSharp.dll + $(KSPManagedRelativePath)/Assembly-CSharp.dll property + + - - - $(KSP_ROOT) + $(KSP_ROOT) environment variable @@ -73,86 +110,38 @@ + - - $(SolutionDir)KSP + $(SolutionDir)KSP solution directory + - $(ReferencePath) reference path + - $(SteamKSPRoot) steam - - - $(KSPRoot)/$(ManagedRelativePath) + + + $(KSPRoot)/$(KSPManagedRelativePath) Program - $(KSPRoot)\$(KSPExecutable) + $(KSPRoot)/$(KSPExecutable) $(KSPRoot) portable - - - - true - - true - - false - $(ManagedPath) - - - - - - System (KSP/Mono) - False - - - System (KSP/Mono) - False - - - System.Core (KSP/Mono) - False - - - System.Xml (KSP/Mono) - False - - - - - UnityEngine - False - - - - - Assembly-CSharp - False - - - Assembly-CSharp-firstpass - False - - - - + diff --git a/KSPCommon.targets b/KSPCommon.targets index fdc4607..a377d89 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -8,8 +8,57 @@ - + + > + + true + + true + + false + $(ManagedPath) + true + + + + + + System (KSP/Mono) + False + + + System (KSP/Mono) + False + + + System.Core (KSP/Mono) + False + + + System.Xml (KSP/Mono) + False + + + + + UnityEngine + False + + + + + Assembly-CSharp + False + + + Assembly-CSharp-firstpass + False + + + + - - - + + - + + - - + + @@ -82,9 +132,7 @@ - + @@ -110,7 +158,7 @@ Otherwise 0.0 is used (no minimum version) --> + Condition=" '$(GenerateKSPAssemblyDependencyAttributes)' == 'true' "> $([System.String]::Copy('%(Reference.identity)').Split(',')[0]) @@ -156,7 +204,9 @@ - + $(ProjectName) diff --git a/docs/msbuild/generating-version-files.md b/docs/msbuild/generating-version-files.md index 43e72c5..ede9715 100644 --- a/docs/msbuild/generating-version-files.md +++ b/docs/msbuild/generating-version-files.md @@ -8,7 +8,7 @@ To use, add the following to your csproj, filling in the URLs and paths for your - $(RepoRootPath)GameData/MyMod/mymod.version + $(KSPModRoot)/mymod.version https://github.com/username/repo/releases/latest/download/mymod.version https://github.com/username.repo/releases/latest @@ -44,7 +44,7 @@ The `include` value can also be set to a json file including any other values yo - $(RepoRootPath)GameData/MyMod/mymod.version + $(KSPModRoot)/mymod.version ``` \ No newline at end of file diff --git a/docs/msbuild/properties.md b/docs/msbuild/properties.md index 97d35e2..6eea55b 100644 --- a/docs/msbuild/properties.md +++ b/docs/msbuild/properties.md @@ -4,20 +4,20 @@ This property should be set to the root directory of your KSP install. You should not set this in your csproj, see [Locating your KSP Install](getting-started.md/#locating-your-ksp-install) ``` -```{confval} RepoRootPath +```{confval} KSPModRoot --- -default: `$(SolutionDir)` +default: `$(ProjectDir)/../GameData/$(ProjectName)/` --- -specifies the root directory of your mod repository. Generally you'll want to set this to be relative to the csproj file using `$(MSBuildThisFileDirectory)`. +specifies the root directory of your mod (the folder that gets placed into GameData). Generally you'll want to set this to be relative to the csproj file using `$(MSBuildThisFileDirectory)`. ``` -```{confval} BinariesOutputRelativePath +```{confval} KSPModPluginFolder --- -default: `GameData/$(SolutionName)` +default: `$(KSPModRoot)/Plugins` --- -the directory where compiled binaries should be copied. This is relative to the `RepoRootPath`. The binaries will be copied to this directory after each build. +the directory where compiled binaries should be copied. This is relative to the `KSPModRoot`. The binaries will be copied to this directory after each build. ``` ```{confval} CKANCompatibleVersions @@ -36,14 +36,14 @@ If set to `true`, automatically generates the `KSPAssembly` for your assembly fr If set to `true`, automatically generates `KSPAssemblyDependency` attributes for each dependency. Dependencies should have either the `CKANIdentifier` metadata or `KSPAssemblyName` metadata. Versions can be supplied with `CKANVersion` or `KSPAssemblyVersion`. ``` -```{confval} ReferenceUnityAssemblies +```{confval} ReferenceKSPUnityAssemblies --- default: `true` --- If set to `true`, adds assembly references to all UnityEngine assemblies in the KSP install. You can set this to `false` to opt out of this behavior if you want to create a pure C# assembly that does not depend on Unity. ``` -```{confval} ReferenceKSPAssemblies +```{confval} ReferenceKSPGameAssemblies --- default: `true` --- diff --git a/tests/plugin-mod-nuget/plugin-mod.csproj b/tests/plugin-mod-nuget/plugin-mod.csproj index 68f03b2..a8ff565 100644 --- a/tests/plugin-mod-nuget/plugin-mod.csproj +++ b/tests/plugin-mod-nuget/plugin-mod.csproj @@ -22,8 +22,8 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginModNuget - $(MSBuildThisFileDirectory) - GameData/plugin-mod-nuget + $(MSBuildThisFileDirectory)GameData/plugin-mod-nuget/ + $(KSPModRoot)/ @@ -39,12 +39,7 @@ - $(RepoRootPath)$(BinariesOutputRelativePath)/plugin-mod-nuget.version + $(KSPModRoot)/plugin-mod-nuget.version - - - true - true - diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index 4a3cc0f..ce4a55b 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -17,8 +17,8 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginMod - $(MSBuildThisFileDirectory) - GameData/plugin-mod + $(MSBuildThisFileDirectory)GameData/plugin-mod/ + $(KSPModRoot)/ @@ -34,14 +34,9 @@ - $(RepoRootPath)$(BinariesOutputRelativePath)/plugin-mod.version + $(KSPModRoot)/plugin-mod.version - - true - true - - From 5fa2acd600ed54be4d1e73e7defd3cd734178ac3 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 01:31:45 -0700 Subject: [PATCH 02/36] fix syntax error --- KSPCommon.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index a377d89..f5210d0 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -9,7 +9,7 @@ - > + true From 08ad322cdb5533ecc2426d7024f0f9f74db89349 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 17:02:04 -0700 Subject: [PATCH 03/36] Fix logic error double-importing system assemblies --- KSPCommon.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index f5210d0..3b2da26 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -9,7 +9,7 @@ - + true From 31852ae7185860db8883b15c509228bc01174805 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 18:22:40 -0700 Subject: [PATCH 04/36] move references back where they belong, fix whitespace --- KSPCommon.props | 111 +++++++++++++++++++++++++++------------------- KSPCommon.targets | 51 --------------------- 2 files changed, 66 insertions(+), 96 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index c061bc3..fd31c0a 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -7,77 +7,47 @@ - - true - - - true - - - true - + true + true + true - - true - + true - - true - + true - - true - + true - - true - + true - - 1.12 1.11 1.10 1.9 1.8 - + 1.12 1.11 1.10 1.9 1.8 - - KSP_x64_Data/Managed - - - KSP.app/Contents/Resources/Data/Managed - - - KSP_Data/Managed - + KSP_x64_Data/Managed + KSP.app/Contents/Resources/Data/Managed + KSP_Data/Managed KSP_x64.exe KSP.app/Contents/MacOS/KSP KSP.x86_64 - - C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - - - $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program - + C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program + $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program - - $(ProjectDir)/../GameData/$(ProjectName)/ - - - $(KSPModGameData)/Plugins/ - + $(ProjectDir)/../GameData/$(ProjectName)/ + $(KSPModGameData)/Plugins/ @@ -141,6 +111,57 @@ portable + + + + true + + true + + false + $(ManagedPath) + true + + + + + + + System (KSP/Mono) + False + + + System (KSP/Mono) + False + + + System.Core (KSP/Mono) + False + + + System.Xml (KSP/Mono) + False + + + + + UnityEngine + False + + + + + Assembly-CSharp + False + + + Assembly-CSharp-firstpass + False + + + + diff --git a/KSPCommon.targets b/KSPCommon.targets index 3b2da26..506a6d5 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -7,57 +7,6 @@ - - - - - true - - true - - false - $(ManagedPath) - true - - - - - - System (KSP/Mono) - False - - - System (KSP/Mono) - False - - - System.Core (KSP/Mono) - False - - - System.Xml (KSP/Mono) - False - - - - - UnityEngine - False - - - - - Assembly-CSharp - False - - - Assembly-CSharp-firstpass - False - - - - $(ProjectDir)/../GameData/$(ProjectName)/ - $(KSPModGameData)/Plugins/ + + diff --git a/KSPCommon.targets b/KSPCommon.targets index 506a6d5..0188e67 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -29,8 +29,8 @@ - - + + diff --git a/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj b/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj index b269787..72bb719 100644 --- a/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj +++ b/tests/plugin-mod-legacy/PluginModLegacy/plugin-mod-legacy.csproj @@ -50,10 +50,6 @@ prompt MinimumRecommendedRules.ruleset - - $(MSBuildThisFileDirectory)../ - GameData/plugin-mod-legacy - diff --git a/tests/plugin-mod-nuget/plugin-mod.csproj b/tests/plugin-mod-nuget/plugin-mod.csproj index a8ff565..d406465 100644 --- a/tests/plugin-mod-nuget/plugin-mod.csproj +++ b/tests/plugin-mod-nuget/plugin-mod.csproj @@ -22,8 +22,6 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginModNuget - $(MSBuildThisFileDirectory)GameData/plugin-mod-nuget/ - $(KSPModRoot)/ diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index ce4a55b..38f7614 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -17,8 +17,6 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginMod - $(MSBuildThisFileDirectory)GameData/plugin-mod/ - $(KSPModRoot)/ From e2b205e34740eb6005e1250e16f00e39d66b6661 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 19:01:43 -0700 Subject: [PATCH 06/36] fix project path/name variables --- KSPCommon.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.props b/KSPCommon.props index 281e775..8e1e5e0 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -46,7 +46,7 @@ - $(ProjectDir)/../GameData/$(ProjectName)/ + $(MSBuildProjectDirectory)/../GameData/$(MSBuildProjectName)/ From cdc5ef664a38ac5898afbdc8d188d67879c4cc87 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 19:12:03 -0700 Subject: [PATCH 07/36] fix test mod roots --- tests/plugin-mod-nuget/plugin-mod.csproj | 1 + tests/plugin-mod/plugin-mod.csproj | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/plugin-mod-nuget/plugin-mod.csproj b/tests/plugin-mod-nuget/plugin-mod.csproj index d406465..8fa0bd4 100644 --- a/tests/plugin-mod-nuget/plugin-mod.csproj +++ b/tests/plugin-mod-nuget/plugin-mod.csproj @@ -22,6 +22,7 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginModNuget + $(MSBuildThisFileDirectory) diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index 38f7614..9d1b7a8 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -17,6 +17,7 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginMod + $(MSBuildThisFileDirectory) From ce6db033bad9c310e4b9243b3059bda64b381160 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 19:14:22 -0700 Subject: [PATCH 08/36] oops --- tests/plugin-mod-nuget/plugin-mod.csproj | 2 +- tests/plugin-mod/plugin-mod.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/plugin-mod-nuget/plugin-mod.csproj b/tests/plugin-mod-nuget/plugin-mod.csproj index 8fa0bd4..0e5ec71 100644 --- a/tests/plugin-mod-nuget/plugin-mod.csproj +++ b/tests/plugin-mod-nuget/plugin-mod.csproj @@ -22,7 +22,7 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginModNuget - $(MSBuildThisFileDirectory) + $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index 9d1b7a8..1feffeb 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -17,7 +17,7 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginMod - $(MSBuildThisFileDirectory) + $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) From 1c41d5fac02c818b0c8461348b56b5d710ccf566 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 13 Jul 2025 19:27:50 -0700 Subject: [PATCH 09/36] Rename properties to begin with KSPBT Except the CKAN ones because those are self-evident --- .github/actions/compile/action.yml | 2 +- KSPBuildTools.csproj | 2 +- KSPCommon.props | 113 +++++++++++------------ KSPCommon.targets | 48 +++++----- docs/msbuild/dependencies.md | 18 ++-- docs/msbuild/generating-version-files.md | 4 +- docs/msbuild/getting-started.md | 4 +- docs/msbuild/properties.md | 33 +++++-- tests/plugin-mod/plugin-mod.csproj | 6 +- 9 files changed, 121 insertions(+), 109 deletions(-) diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index ab716de..0acac95 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -76,5 +76,5 @@ runs: working-directory: ${{ inputs.working-directory }} run: | dotnet msbuild -p:Configuration=${{ inputs.build-configuration }} \ - -p:KSPManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ + -p:KSPBTManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ ${{ runner.debug && '-v:detailed' }} diff --git a/KSPBuildTools.csproj b/KSPBuildTools.csproj index 4ebf998..cbf382a 100644 --- a/KSPBuildTools.csproj +++ b/KSPBuildTools.csproj @@ -24,7 +24,7 @@ 1701;1702;CS0649;CS1591;NU5128 2024 KSPModdingLibs Contributors KSPBuildTools - $(ProjectDir) + $(ProjectDir) KSPBuildTools README.md KSP Build Tools diff --git a/KSPCommon.props b/KSPCommon.props index 8e1e5e0..ece1800 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -7,20 +7,19 @@ - true - true - true - + true + true + true - true + true - true + true - true + true - true + true 1.12 1.11 1.10 1.9 1.8 @@ -28,32 +27,32 @@ - - KSP_x64_Data/Managed - KSP.app/Contents/Resources/Data/Managed - KSP_Data/Managed + + KSP_x64_Data/Managed + KSP.app/Contents/Resources/Data/Managed + KSP_Data/Managed - KSP_x64.exe - KSP.app/Contents/MacOS/KSP - KSP.x86_64 - C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program + KSP_x64.exe + KSP.app/Contents/MacOS/KSP + KSP.x86_64 + C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program + $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program - $(MSBuildProjectDirectory)/../GameData/$(MSBuildProjectName)/ - - + $(MSBuildProjectDirectory)/../GameData/$(MSBuildProjectName)/ + + - + @@ -65,55 +64,55 @@ - $(KSPManagedRelativePath)/Assembly-CSharp.dll - property + $(KSPBTManagedRelativePath)/Assembly-CSharp.dll + property - + - - $(KSP_ROOT) - environment variable + + $(KSP_ROOT) + environment variable - - - + + + - - $(SolutionDir)KSP - solution directory + + $(SolutionDir)KSP + solution directory - - $(ReferencePath) - reference path + + $(ReferencePath) + reference path - - $(SteamKSPRoot) - steam + + $(KSPBTSteamGameRoot) + steam - - - $(KSPRoot)/$(KSPManagedRelativePath) + + + $(KSPBTGameRoot)/$(KSPBTManagedRelativePath) Program - $(KSPRoot)/$(KSPExecutable) - $(KSPRoot) + $(KSPBTGameRoot)/$(KSPBTGameExecutable) + $(KSPBTGameRoot) portable - + true @@ -121,42 +120,42 @@ false - $(ManagedPath) + $(KSPBTManagedPath) true - - + + System (KSP/Mono) False - + System (KSP/Mono) False - + System.Core (KSP/Mono) False - + System.Xml (KSP/Mono) False - - + + UnityEngine False - - + + Assembly-CSharp False - + Assembly-CSharp-firstpass False diff --git a/KSPCommon.targets b/KSPCommon.targets index 0188e67..1cde14c 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -4,33 +4,33 @@ - + - - + + Condition="'$(KSPBTGameRoot)' == ''"/> - <_KSPRootMessage Include="KSPRoot Candidates:"/> - <_KSPRootMessage Include="Candidate: %(KSPRootCandidate.source) from %(KSPRootCandidate.identity)"/> - <_KSPRootMessage Include="Chosen KSPRoot: $(KSPRoot) in $(KSPRootSource)" Condition="'$(KSPRoot)' != ''"/> + <_GameRootMessage Include="KSPBTGameRoot Candidates:"/> + <_GameRootMessage Include="Candidate: %(KSPBTGameRootCandidate.source) from %(KSPBTGameRootCandidate.identity)"/> + <_GameRootMessage Include="Chosen KSPBTGameRoot: $(KSPBTGameRoot) in $(KSPBTGameRootSource)" Condition="'$(KSPBTGameRoot)' != ''"/> - + - + - - + <_BinariesToCopy Include="$(TargetDir)/**/*.dll"/> + <_BinariesToCopy Include="$(TargetDir)/**/*.pdb" Condition="'$(Condition)' == 'Debug'"/> - - + + @@ -45,14 +45,14 @@ <_CKANDependency Include="@(CKANDependency)"/> - @(_CKANDependency, ' ') + <_CKANDependencyList>@(_CKANDependency, ' ') - <_CKANCommands Include="compat add --gamedir "$(KSPROOT)" %(_CKANCompatibleVersionItems.Identity)" + <_CKANCommands Include="compat add --gamedir "$(KSPBTGameRoot)" %(_CKANCompatibleVersionItems.Identity)" Condition=" '$(CKANCompatibleVersions)' != '' "/> - <_CKANCommands Include="install --no-recommends --gamedir "$(KSPROOT)" $(CKANDependencyList)" Condition="'$(CKANDependencyList)' != ''"/> + <_CKANCommands Include="install --no-recommends --gamedir "$(KSPBTGameRoot)" $(_CKANDependencyList)" Condition="'$(CKANDependencyList)' != ''"/> @@ -64,7 +64,7 @@ - + @@ -82,8 +82,8 @@ - + <_Parameter1>$(AssemblyName) @@ -106,8 +106,8 @@ Otherwise CKANVersion is used. Otherwise 0.0 is used (no minimum version) --> - + $([System.String]::Copy('%(Reference.identity)').Split(',')[0]) @@ -153,9 +153,9 @@ - + Condition= " '$(KSPBTGenerateVersionFile)' == 'true' "> $(ProjectName) diff --git a/docs/msbuild/dependencies.md b/docs/msbuild/dependencies.md index 9ef01ea..3ff72a6 100644 --- a/docs/msbuild/dependencies.md +++ b/docs/msbuild/dependencies.md @@ -6,15 +6,15 @@ KSPBuildTools can help manage other mods that you depend on Mod DLLs should be referenced as with any other DLLs, like so. See [the Microsoft docs on Reference items](https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022#reference) for more info. Make sure that `False`{l=xml} is set or the DLL will be copied to your output directory. -the {confval}`KSPRoot` property can be used to reference the KSP install wherever it is. +the {confval}`KSPBTGameRoot` property can be used to reference the KSP install wherever it is. ```xml - + False - $(KSPRoot)/GameData/000_Harmony/0Harmony.dll + $(KSPBTGameRoot)/GameData/000_Harmony/0Harmony.dll False @@ -27,7 +27,7 @@ KSPBuildTools can install CKAN mods automatically when built. This is useful for ```xml - + False ModuleManager @@ -42,7 +42,7 @@ You can also mark explicit versions to install. ```xml - + False ModuleManager 4.2.3 @@ -59,7 +59,7 @@ KSP mods should mark their dependency DLLs using the `KSPAssemblyDependency` att `[assembly: KSPAssemblyDependency("0Harmony", 0, 0, 0)]`{l=csharp} -If the {confval}`GenerateKSPAssemblyDependencyAttributes` property is set to `true`, KSPBuildTools will generate these attributes automatically. It uses any `Reference` item that has a `` or `` metadata value. +If the {confval}`KSPBTGenerateDependencyAttributes` property is set to `true`, KSPBuildTools will generate these attributes automatically. It uses any `Reference` item that has a `` or `` metadata value. The assembly name is set to the `` metadata value, and falls back to the `` metadata value. @@ -68,7 +68,7 @@ The version is taken from the `` metadata value, however lea ```xml - + False TweakScaleRescaled Scale @@ -78,7 +78,7 @@ The version is taken from the `` metadata value, however lea - true - true + true + true ``` \ No newline at end of file diff --git a/docs/msbuild/generating-version-files.md b/docs/msbuild/generating-version-files.md index ede9715..d407402 100644 --- a/docs/msbuild/generating-version-files.md +++ b/docs/msbuild/generating-version-files.md @@ -8,7 +8,7 @@ To use, add the following to your csproj, filling in the URLs and paths for your - $(KSPModRoot)/mymod.version + $(KSPBTModRoot)/mymod.version https://github.com/username/repo/releases/latest/download/mymod.version https://github.com/username.repo/releases/latest @@ -44,7 +44,7 @@ The `include` value can also be set to a json file including any other values yo - $(KSPModRoot)/mymod.version + $(KSPBTModRoot)/mymod.version ``` \ No newline at end of file diff --git a/docs/msbuild/getting-started.md b/docs/msbuild/getting-started.md index 27ec814..3863937 100644 --- a/docs/msbuild/getting-started.md +++ b/docs/msbuild/getting-started.md @@ -74,9 +74,9 @@ KSPBuildTools needs to know where you have KSP installed in order to reference t There are several options for this. KSPBuildTools will choose in the following order. Either [autodiscovery in the solution directory](#solution-directory) or [setting a reference path in a .user file](#environment-variable) are the recommended methods for most users. -### KSPRoot MSBuild Property +### KSPBTGameRoot MSBuild Property -If the {confval}`KSPRoot` MSBuild property is already set, KSPBuildTools will use it as-is. This can be set in your .csproj.user file. +If the {confval}`KSPBTGameRoot` MSBuild property is already set, KSPBuildTools will use it as-is. This can be set in your .csproj.user file. ### Environment Variable diff --git a/docs/msbuild/properties.md b/docs/msbuild/properties.md index 6eea55b..02b3937 100644 --- a/docs/msbuild/properties.md +++ b/docs/msbuild/properties.md @@ -1,23 +1,23 @@ # MSBuild Properties -```{confval} KSPRoot +```{confval} KSPBTGameRoot This property should be set to the root directory of your KSP install. You should not set this in your csproj, see [Locating your KSP Install](getting-started.md/#locating-your-ksp-install) ``` -```{confval} KSPModRoot +```{confval} KSPBTModRoot --- -default: `$(ProjectDir)/../GameData/$(ProjectName)/` +default: `$(MSBuildProjectDir)/../GameData/$(MSBuildProjectName)/` --- specifies the root directory of your mod (the folder that gets placed into GameData). Generally you'll want to set this to be relative to the csproj file using `$(MSBuildThisFileDirectory)`. ``` -```{confval} KSPModPluginFolder +```{confval} KSPBTModPluginFolder --- -default: `$(KSPModRoot)/Plugins` +default: `Plugins` --- -the directory where compiled binaries should be copied. This is relative to the `KSPModRoot`. The binaries will be copied to this directory after each build. +the directory where compiled binaries should be copied. This is relative to the `KSPBTMosRoot`. The DLLs will be copied to this directory after each build. ``` ```{confval} CKANCompatibleVersions @@ -28,22 +28,35 @@ default: `1.12 1.11 1.10 1.9 1.8` Used by the `CKANInstall` target to set additional KSP versions to treat as compatible when installing ``` -```{confval} GenerateKSPAssemblyAttribute +```{confval} KSPBTGenerateAssemblyAttribute +--- +default: `true` +--- If set to `true`, automatically generates the `KSPAssembly` for your assembly from the `Version` property. ``` -```{confval} GenerateKSPAssemblyDependencyAttributes +```{confval} KSPBTGenerateDependencyAttributes +--- +default: `true` +--- If set to `true`, automatically generates `KSPAssemblyDependency` attributes for each dependency. Dependencies should have either the `CKANIdentifier` metadata or `KSPAssemblyName` metadata. Versions can be supplied with `CKANVersion` or `KSPAssemblyVersion`. ``` -```{confval} ReferenceKSPUnityAssemblies +```{confval} KSPBTReferenceSystemAssemblies +--- +default: `true` +--- +If set to `true`, adds assembly references to Mono System DLLs. +``` + +```{confval} KSPBTReferenceUnityAssemblies --- default: `true` --- If set to `true`, adds assembly references to all UnityEngine assemblies in the KSP install. You can set this to `false` to opt out of this behavior if you want to create a pure C# assembly that does not depend on Unity. ``` -```{confval} ReferenceKSPGameAssemblies +```{confval} KSPBTReferenceGameAssemblies --- default: `true` --- diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index 1feffeb..57edfbc 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -17,13 +17,13 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginMod - $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) + $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) - $(KSPRoot)/GameData/000_Harmony/0Harmony.dll + $(KSPBTGameRoot)/GameData/000_Harmony/0Harmony.dll Harmony2 2.2.1.0 False @@ -33,7 +33,7 @@ - $(KSPModRoot)/plugin-mod.version + $(KSPBTModRoot)/plugin-mod.version From 769b65e9fd91af80c2149edfb3b72ec989fd6ebb Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 14 Jul 2025 23:08:43 -0700 Subject: [PATCH 10/36] add ability to declare mod dependencies with ModReference items --- KSPCommon.targets | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/KSPCommon.targets b/KSPCommon.targets index 1cde14c..f26a71a 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -61,6 +61,7 @@ + @@ -72,6 +73,23 @@ + + + + + %(ModReference.identity) + + + + + From 0b686197eec5d5e76a4dd6a7f6bf7f6e57dd50c0 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Tue, 15 Jul 2025 22:32:00 -0700 Subject: [PATCH 11/36] Update changelog to reflect recent changes --- CHANGELOG.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd420c8..4c01fb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,25 @@ All notable changes to this project will be documented in this file +## Unreleased + +### Msbuild + +- Renamed global msbuild properties to have the `KSPBT` prefix to avoid namespace collisions with other frameworks + - `KSPRoot` is now `KSPBTGameRoot`. It should no longer be referenced within a .csproj file + - `RepoRootPath` is now `KSPBTModRoot`, and should now point to the mod folder within GameData rather than the + root of a git repo + - `BinariesOutputRelativePath` is now `KSPBTModPluginFolder` + - `GenerateKSPAssemblyAttribute` is now `KSPBTGenerateAssemblyAttribute` and defaults to true + - `GenerateKSPAssemblyDependencyAttributes` is now `KSPBTGenerateDependencyAttributes` and defaults to true + - `ReferenceUnityAssemblies` is now `KSPBTReferenceUnityAssemblies` + - `ReferenceKSPAssemblies` is now `KSPBTReferenceGameAssemblies` +- Added the `KSPBTReferenceSystemAssemblies` property to control referencing the mono system DLLs within the KSP + managed folder. Setting this property to false will load the implicit framework DLLs instead. +- Mod dependencies should now be declared with + `ModReference` items. This avoids the need for the KSP install path to be known at evaluation time. + + ## 0.0.4 - 2025-06-15 ### Library From 96c6a69d7cbe3d6229f9d1b7ecfaf65bb1fe78ee Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Tue, 15 Jul 2025 23:41:50 -0700 Subject: [PATCH 12/36] Move references back to the targets file --- KSPCommon.props | 51 ----------------------------------------------- KSPCommon.targets | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 51 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index ece1800..f5bf28d 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -111,57 +111,6 @@ portable - - - - true - - true - - false - $(KSPBTManagedPath) - true - - - - - - - System (KSP/Mono) - False - - - System (KSP/Mono) - False - - - System.Core (KSP/Mono) - False - - - System.Xml (KSP/Mono) - False - - - - - UnityEngine - False - - - - - Assembly-CSharp - False - - - Assembly-CSharp-firstpass - False - - - - diff --git a/KSPCommon.targets b/KSPCommon.targets index f26a71a..9929dd9 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -2,6 +2,56 @@ + + + + true + + true + + false + $(KSPBTManagedPath) + true + + + + + + + System (KSP/Mono) + False + + + System (KSP/Mono) + False + + + System.Core (KSP/Mono) + False + + + System.Xml (KSP/Mono) + False + + + + + UnityEngine + False + + + + + Assembly-CSharp + False + + + Assembly-CSharp-firstpass + False + + + From a2a8bd17bcefde99d8abae7441b5869ac7cf495e Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Wed, 16 Jul 2025 00:22:24 -0700 Subject: [PATCH 13/36] Fix some bugs with CKAN install and tests --- KSPCommon.targets | 2 +- tests/plugin-mod-nuget/plugin-mod.csproj | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index 9929dd9..e49390b 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -116,7 +116,7 @@ - + diff --git a/tests/plugin-mod-nuget/plugin-mod.csproj b/tests/plugin-mod-nuget/plugin-mod.csproj index 0e5ec71..6eead32 100644 --- a/tests/plugin-mod-nuget/plugin-mod.csproj +++ b/tests/plugin-mod-nuget/plugin-mod.csproj @@ -22,13 +22,13 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginModNuget - $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) + $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) - $(KSPRoot)/GameData/000_Harmony/0Harmony.dll + $(KSPBTGameRoot)/GameData/000_Harmony/0Harmony.dll Harmony2 2.2.1.0 False @@ -38,7 +38,7 @@ - $(KSPModRoot)/plugin-mod-nuget.version + $(KSPBTModRoot)/plugin-mod-nuget.version From bd0a6ec18dad8ef6c574e28747cdb5d4b9054d59 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Thu, 17 Jul 2025 21:58:12 -0700 Subject: [PATCH 14/36] try something --- KSPCommon.props | 13 +++++++++++++ KSPCommon.targets | 14 -------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index f5bf28d..d696f3a 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -111,6 +111,19 @@ portable + + + + true + + true + + false + $(KSPBTManagedPath) + true + + diff --git a/KSPCommon.targets b/KSPCommon.targets index e49390b..3652aca 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -2,20 +2,6 @@ - - - - true - - true - - false - $(KSPBTManagedPath) - true - - - From e5bceffbd35e7c8dc77f016adca6a2b8140afac7 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sat, 19 Jul 2025 11:29:11 -0700 Subject: [PATCH 15/36] add an sln makes debugging way easier in Rider --- .../workflows/internal-test-plugin-nuget.yml | 2 +- .gitignore | 6 ++++ KSPBuildTools.csproj | 4 --- KSPBuildTools.sln | 34 +++++++++++++++++++ ...gin-mod.csproj => plugin-mod-nuget.csproj} | 1 + 5 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 KSPBuildTools.sln rename tests/plugin-mod-nuget/{plugin-mod.csproj => plugin-mod-nuget.csproj} (97%) diff --git a/.github/workflows/internal-test-plugin-nuget.yml b/.github/workflows/internal-test-plugin-nuget.yml index 9519ca2..ffbedbc 100644 --- a/.github/workflows/internal-test-plugin-nuget.yml +++ b/.github/workflows/internal-test-plugin-nuget.yml @@ -39,7 +39,7 @@ jobs: with: ksp-zip-url: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip working-directory: ${{ env.TESTDIR }} - solution-file-path: plugin-mod.csproj + solution-file-path: plugin-mod-nuget.csproj env: KSPBuildToolsVersion: ${{ inputs.package-version }} diff --git a/.gitignore b/.gitignore index 6851198..8842667 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,12 @@ bin obj *.nupkg +packages # docs docs/_build + +# misc +.DS_Store +.idea +*.user diff --git a/KSPBuildTools.csproj b/KSPBuildTools.csproj index cbf382a..59be6b4 100644 --- a/KSPBuildTools.csproj +++ b/KSPBuildTools.csproj @@ -50,8 +50,4 @@ - - - - \ No newline at end of file diff --git a/KSPBuildTools.sln b/KSPBuildTools.sln new file mode 100644 index 0000000..5b01e79 --- /dev/null +++ b/KSPBuildTools.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KSPBuildTools", "KSPBuildTools.csproj", "{F5D90A2D-BF85-4849-9A1B-AD53EE814149}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "plugin-mod-legacy", "tests\plugin-mod-legacy\PluginModLegacy\plugin-mod-legacy.csproj", "{F19C7AB4-50C2-4378-9673-CC039CA12E10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "plugin-mod-nuget", "tests\plugin-mod-nuget\plugin-mod-nuget.csproj", "{4F531716-DB82-4AD4-8270-DFB32EE18A41}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "plugin-mod", "tests\plugin-mod\plugin-mod.csproj", "{F0E30935-74A7-446F-A30C-5D1D0E525EC5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {F5D90A2D-BF85-4849-9A1B-AD53EE814149}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F5D90A2D-BF85-4849-9A1B-AD53EE814149}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F5D90A2D-BF85-4849-9A1B-AD53EE814149}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F5D90A2D-BF85-4849-9A1B-AD53EE814149}.Release|Any CPU.Build.0 = Release|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F19C7AB4-50C2-4378-9673-CC039CA12E10}.Release|Any CPU.Build.0 = Release|Any CPU + {4F531716-DB82-4AD4-8270-DFB32EE18A41}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4F531716-DB82-4AD4-8270-DFB32EE18A41}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4F531716-DB82-4AD4-8270-DFB32EE18A41}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4F531716-DB82-4AD4-8270-DFB32EE18A41}.Release|Any CPU.Build.0 = Release|Any CPU + {F0E30935-74A7-446F-A30C-5D1D0E525EC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F0E30935-74A7-446F-A30C-5D1D0E525EC5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F0E30935-74A7-446F-A30C-5D1D0E525EC5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F0E30935-74A7-446F-A30C-5D1D0E525EC5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/tests/plugin-mod-nuget/plugin-mod.csproj b/tests/plugin-mod-nuget/plugin-mod-nuget.csproj similarity index 97% rename from tests/plugin-mod-nuget/plugin-mod.csproj rename to tests/plugin-mod-nuget/plugin-mod-nuget.csproj index 6eead32..3d60b1d 100644 --- a/tests/plugin-mod-nuget/plugin-mod.csproj +++ b/tests/plugin-mod-nuget/plugin-mod-nuget.csproj @@ -3,6 +3,7 @@ *-* + plugin-mod From c68f3f12e39f188f29a19f6d7236bd4c0c16ae32 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sat, 19 Jul 2025 22:33:45 -0700 Subject: [PATCH 16/36] More property renames and additions --- .github/actions/compile/action.yml | 2 +- CHANGELOG.md | 18 +-- KSPBuildTools.csproj | 2 +- KSPCommon.props | 115 ++++++++--------- KSPCommon.targets | 118 +++++++++--------- .../{properties.md => configuration.md} | 37 +++--- docs/msbuild/dependencies.md | 18 +-- docs/msbuild/generating-version-files.md | 4 +- docs/msbuild/getting-started.md | 4 +- docs/msbuild/index.md | 2 +- .../plugin-mod-nuget/plugin-mod-nuget.csproj | 6 +- tests/plugin-mod/plugin-mod.csproj | 6 +- 12 files changed, 171 insertions(+), 161 deletions(-) rename docs/msbuild/{properties.md => configuration.md} (64%) diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index 0acac95..54b33fe 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -76,5 +76,5 @@ runs: working-directory: ${{ inputs.working-directory }} run: | dotnet msbuild -p:Configuration=${{ inputs.build-configuration }} \ - -p:KSPBTManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ + -p:_KSPBT_ManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ ${{ runner.debug && '-v:detailed' }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 4c01fb6..117803f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,16 +6,16 @@ All notable changes to this project will be documented in this file ### Msbuild -- Renamed global msbuild properties to have the `KSPBT` prefix to avoid namespace collisions with other frameworks - - `KSPRoot` is now `KSPBTGameRoot`. It should no longer be referenced within a .csproj file - - `RepoRootPath` is now `KSPBTModRoot`, and should now point to the mod folder within GameData rather than the +- Renamed global msbuild properties to have the `KSPBT_` prefix to avoid namespace collisions with other frameworks + - `KSPRoot` is now `KSPBT_GameRoot`. It should no longer be referenced within a .csproj file + - `RepoRootPath` is now `KSPBT_ModRoot`, and should now point to the mod folder within GameData rather than the root of a git repo - - `BinariesOutputRelativePath` is now `KSPBTModPluginFolder` - - `GenerateKSPAssemblyAttribute` is now `KSPBTGenerateAssemblyAttribute` and defaults to true - - `GenerateKSPAssemblyDependencyAttributes` is now `KSPBTGenerateDependencyAttributes` and defaults to true - - `ReferenceUnityAssemblies` is now `KSPBTReferenceUnityAssemblies` - - `ReferenceKSPAssemblies` is now `KSPBTReferenceGameAssemblies` -- Added the `KSPBTReferenceSystemAssemblies` property to control referencing the mono system DLLs within the KSP + - `BinariesOutputRelativePath` is now `KSPBT_ModPluginFolder` + - `GenerateKSPAssemblyAttribute` is now `KSPBT_GenerateAssemblyAttribute` and defaults to true + - `GenerateKSPAssemblyDependencyAttributes` is now `KSPBT_GenerateDependencyAttributes` and defaults to true + - `ReferenceUnityAssemblies` is now `KSPBT_ReferenceUnityAssemblies` + - `ReferenceKSPAssemblies` is now `KSPBT_ReferenceGameAssemblies` +- Added the `KSPBT_ReferenceSystemAssemblies` property to control referencing the mono system DLLs within the KSP managed folder. Setting this property to false will load the implicit framework DLLs instead. - Mod dependencies should now be declared with `ModReference` items. This avoids the need for the KSP install path to be known at evaluation time. diff --git a/KSPBuildTools.csproj b/KSPBuildTools.csproj index 59be6b4..56d4565 100644 --- a/KSPBuildTools.csproj +++ b/KSPBuildTools.csproj @@ -24,7 +24,7 @@ 1701;1702;CS0649;CS1591;NU5128 2024 KSPModdingLibs Contributors KSPBuildTools - $(ProjectDir) + $(ProjectDir) KSPBuildTools README.md KSP Build Tools diff --git a/KSPCommon.props b/KSPCommon.props index d696f3a..9be20b8 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -4,55 +4,61 @@ true - + + + $(MSBuildProjectDirectory)/../GameData/$(MSBuildProjectName)/ + + + + + + 1.12 1.11 1.10 1.9 1.8 + - true - true - true + true + true + true + true - true + true + true - true + true - true + true - true - - 1.12 1.11 1.10 1.9 1.8 + true - - - - KSP_x64_Data/Managed - KSP.app/Contents/Resources/Data/Managed - KSP_Data/Managed - + + + + false + + - - KSP_x64.exe - KSP.app/Contents/MacOS/KSP - KSP.x86_64 - C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program - $(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program + + + <_KSPBT_ManagedRelativePath Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">KSP_x64_Data/Managed + <_KSPBT_ManagedRelativePath Condition=" $([MSBuild]::IsOsPlatform('OSX')) ">KSP.app/Contents/Resources/Data/Managed + <_KSPBT_ManagedRelativePath Condition=" $([MSBuild]::IsOsPlatform('Linux')) ">KSP_Data/Managed - - - - $(MSBuildProjectDirectory)/../GameData/$(MSBuildProjectName)/ - - + <_KSPBT_GameExecutable Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">KSP_x64.exe + <_KSPBT_GameExecutable Condition=" $([MSBuild]::IsOsPlatform('OSX')) ">KSP.app/Contents/MacOS/KSP + <_KSPBT_GameExecutable Condition=" $([MSBuild]::IsOsPlatform('Linux')) ">KSP.x86_64 + <_KSPBT_SteamGameRoot Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">C:\Program Files (x86)\Steam\steamapps\common\Kerbal Space Program + <_KSPBT_SteamGameRoot Condition=" $([MSBuild]::IsOsPlatform('OSX')) ">$(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program - + @@ -64,50 +70,45 @@ - $(KSPBTManagedRelativePath)/Assembly-CSharp.dll - property + $(_KSPBT_ManagedRelativePath)/Assembly-CSharp.dll + property - + - - $(KSP_ROOT) - environment variable + + $(KSP_ROOT) + environment variable - - - + + + - - $(SolutionDir)KSP - solution directory + + $(SolutionDir)KSP + solution directory - - $(ReferencePath) - reference path + + $(ReferencePath) + reference path - - $(KSPBTSteamGameRoot) - steam - - - - - $(KSPBTGameRoot)/$(KSPBTManagedRelativePath) + + $(_KSPBT_SteamGameRoot) + steam Program - $(KSPBTGameRoot)/$(KSPBTGameExecutable) - $(KSPBTGameRoot) + $(KSPBT_GameRoot)/$(_KSPBT_GameExecutable) + $(KSPBT_GameRoot) portable @@ -120,7 +121,7 @@ false - $(KSPBTManagedPath) + $(KSPBT_ManagedPath) true diff --git a/KSPCommon.targets b/KSPCommon.targets index 3652aca..f1eeeaf 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -2,37 +2,42 @@ + + + $(KSPBT_GameRoot)/$(_KSPBT_ManagedRelativePath) + + - - + + System (KSP/Mono) False - + System (KSP/Mono) False - + System.Core (KSP/Mono) False - + System.Xml (KSP/Mono) False - - + + UnityEngine False - - + + Assembly-CSharp False - + Assembly-CSharp-firstpass False @@ -40,42 +45,43 @@ - + + - - + + Condition="'$(KSPBT_GameRoot)' == ''"/> - <_GameRootMessage Include="KSPBTGameRoot Candidates:"/> - <_GameRootMessage Include="Candidate: %(KSPBTGameRootCandidate.source) from %(KSPBTGameRootCandidate.identity)"/> - <_GameRootMessage Include="Chosen KSPBTGameRoot: $(KSPBTGameRoot) in $(KSPBTGameRootSource)" Condition="'$(KSPBTGameRoot)' != ''"/> + <_GameRootMessage Include="KSPBT_GameRoot Candidates:"/> + <_GameRootMessage Include="Candidate: %(KSPBT_GameRootCandidate.source) from %(KSPBT_GameRootCandidate.identity)"/> + <_GameRootMessage Include="Chosen KSPBT_GameRoot: $(KSPBT_GameRoot) in $(KSPBT_GameRootSource)" Condition="'$(KSPBT_GameRoot)' != ''"/> - + <_BinariesToCopy Include="$(TargetDir)/**/*.dll"/> <_BinariesToCopy Include="$(TargetDir)/**/*.pdb" Condition="'$(Condition)' == 'Debug'"/> - - + + - + - $(BaseIntermediateOutputPath)ckancommands.cache + <_CKANScript>$(BaseIntermediateOutputPath)ckancommands.cache - + - <_CKANCompatibleVersionItems Include="$(CKANCompatibleVersions.Split(' '))"/> + <_CKANCompatibleVersionItems Include="$(KSPBT_KSPBT_CKANCompatibleVersions.Split(' '))"/> <_CKANDependency Include="%(Reference.CKANIdentifier)" Condition="'%(Reference.CKANVersion)' == ''"/> <_CKANDependency Include="%(Reference.CKANIdentifier)=%(Reference.CKANVersion)" Condition="'%(Reference.CKANVersion)' != ''"/> <_CKANDependency Include="@(CKANDependency)"/> @@ -85,59 +91,53 @@ - <_CKANCommands Include="compat add --gamedir "$(KSPBTGameRoot)" %(_CKANCompatibleVersionItems.Identity)" - Condition=" '$(CKANCompatibleVersions)' != '' "/> + <_CKANCommands Include="compat add --gamedir "$(KSPBT_GameRoot)" %(_CKANCompatibleVersionItems.Identity)" + Condition=" '$(KSPBT_CKANCompatibleVersions)' != '' "/> - <_CKANCommands Include="install --no-recommends --gamedir "$(KSPBTGameRoot)" $(_CKANDependencyList)" Condition="'$(CKANDependencyList)' != ''"/> + <_CKANCommands Include="install --no-recommends --gamedir "$(KSPBT_GameRoot)" $(_CKANDependencyList)" Condition="'$(CKANDependencyList)' != ''"/> - + - + - - - - - - - + + + + + - - + + - + + + + - + %(ModReference.identity) - - - - - - - - - - - + <_Parameter1>$(AssemblyName) @@ -160,8 +160,8 @@ Otherwise CKANVersion is used. Otherwise 0.0 is used (no minimum version) --> - + $([System.String]::Copy('%(Reference.identity)').Split(',')[0]) @@ -207,9 +207,9 @@ - + Condition=" '$(KSPBT_GenerateVersionFile)' == 'true' "> $(ProjectName) diff --git a/docs/msbuild/properties.md b/docs/msbuild/configuration.md similarity index 64% rename from docs/msbuild/properties.md rename to docs/msbuild/configuration.md index 02b3937..db02c9e 100644 --- a/docs/msbuild/properties.md +++ b/docs/msbuild/configuration.md @@ -1,10 +1,12 @@ -# MSBuild Properties +# MSBuild Items And Properties -```{confval} KSPBTGameRoot +## Properties + +```{confval} KSPBT_GameRoot This property should be set to the root directory of your KSP install. You should not set this in your csproj, see [Locating your KSP Install](getting-started.md/#locating-your-ksp-install) ``` -```{confval} KSPBTModRoot +```{confval} KSPBT_ModRoot --- default: `$(MSBuildProjectDir)/../GameData/$(MSBuildProjectName)/` --- @@ -12,15 +14,15 @@ default: `$(MSBuildProjectDir)/../GameData/$(MSBuildProjectName)/` specifies the root directory of your mod (the folder that gets placed into GameData). Generally you'll want to set this to be relative to the csproj file using `$(MSBuildThisFileDirectory)`. ``` -```{confval} KSPBTModPluginFolder +```{confval} KSPBT_ModPluginFolder --- -default: `Plugins` +default: `./` --- -the directory where compiled binaries should be copied. This is relative to the `KSPBTMosRoot`. The DLLs will be copied to this directory after each build. +the directory where compiled binaries should be copied. This is relative to the {confval}`KSPBT_ModRoot`. The DLLs will be copied to this directory after each build. ``` -```{confval} CKANCompatibleVersions +```{confval} KSPBT_CKANCompatibleVersions --- default: `1.12 1.11 1.10 1.9 1.8` --- @@ -28,37 +30,44 @@ default: `1.12 1.11 1.10 1.9 1.8` Used by the `CKANInstall` target to set additional KSP versions to treat as compatible when installing ``` -```{confval} KSPBTGenerateAssemblyAttribute +```{confval} KSPBT_GenerateAssemblyAttribute --- default: `true` --- If set to `true`, automatically generates the `KSPAssembly` for your assembly from the `Version` property. ``` -```{confval} KSPBTGenerateDependencyAttributes +```{confval} KSPBT_GenerateDependencyAttributes --- default: `true` --- If set to `true`, automatically generates `KSPAssemblyDependency` attributes for each dependency. Dependencies should have either the `CKANIdentifier` metadata or `KSPAssemblyName` metadata. Versions can be supplied with `CKANVersion` or `KSPAssemblyVersion`. ``` -```{confval} KSPBTReferenceSystemAssemblies +```{confval} KSPBT_ReferenceSystemAssemblies --- default: `true` --- If set to `true`, adds assembly references to Mono System DLLs. ``` -```{confval} KSPBTReferenceUnityAssemblies +```{confval} KSPBT_ReferenceUnityAssemblies +--- +default: `true` +--- +If set to `true`, adds assembly references to all UnityEngine assemblies in the KSP install. +``` + +```{confval} KSPBT_ReferenceGameAssemblies --- default: `true` --- -If set to `true`, adds assembly references to all UnityEngine assemblies in the KSP install. You can set this to `false` to opt out of this behavior if you want to create a pure C# assembly that does not depend on Unity. +If set to `true`, adds references to Assembly-CSharp and Assembly-CSharp-firstpass assemblies from the KSP install. ``` -```{confval} KSPBTReferenceGameAssemblies +```{confval} KSPBT_ReferenceModAssemblies --- default: `true` --- -If set to `true`, adds references to Assembly-CSharp and Assembly-CSharp-firstpass assemblies from the KSP install. You can set this to `false` to opt out of this behavior. +If set to `true`, adds references to the assemblies included in `ModReference` list. ``` diff --git a/docs/msbuild/dependencies.md b/docs/msbuild/dependencies.md index 3ff72a6..9a5abed 100644 --- a/docs/msbuild/dependencies.md +++ b/docs/msbuild/dependencies.md @@ -6,15 +6,15 @@ KSPBuildTools can help manage other mods that you depend on Mod DLLs should be referenced as with any other DLLs, like so. See [the Microsoft docs on Reference items](https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022#reference) for more info. Make sure that `False`{l=xml} is set or the DLL will be copied to your output directory. -the {confval}`KSPBTGameRoot` property can be used to reference the KSP install wherever it is. +the {confval}`KSPBT_GameRoot` property can be used to reference the KSP install wherever it is. ```xml - + False - $(KSPBTGameRoot)/GameData/000_Harmony/0Harmony.dll + $(KSPBT_GameRoot)/GameData/000_Harmony/0Harmony.dll False @@ -27,7 +27,7 @@ KSPBuildTools can install CKAN mods automatically when built. This is useful for ```xml - + False ModuleManager @@ -42,7 +42,7 @@ You can also mark explicit versions to install. ```xml - + False ModuleManager 4.2.3 @@ -59,7 +59,7 @@ KSP mods should mark their dependency DLLs using the `KSPAssemblyDependency` att `[assembly: KSPAssemblyDependency("0Harmony", 0, 0, 0)]`{l=csharp} -If the {confval}`KSPBTGenerateDependencyAttributes` property is set to `true`, KSPBuildTools will generate these attributes automatically. It uses any `Reference` item that has a `` or `` metadata value. +If the {confval}`KSPBT_GenerateDependencyAttributes` property is set to `true`, KSPBuildTools will generate these attributes automatically. It uses any `Reference` item that has a `` or `` metadata value. The assembly name is set to the `` metadata value, and falls back to the `` metadata value. @@ -68,7 +68,7 @@ The version is taken from the `` metadata value, however lea ```xml - + False TweakScaleRescaled Scale @@ -78,7 +78,7 @@ The version is taken from the `` metadata value, however lea - true - true + true + true ``` \ No newline at end of file diff --git a/docs/msbuild/generating-version-files.md b/docs/msbuild/generating-version-files.md index d407402..27d7839 100644 --- a/docs/msbuild/generating-version-files.md +++ b/docs/msbuild/generating-version-files.md @@ -8,7 +8,7 @@ To use, add the following to your csproj, filling in the URLs and paths for your - $(KSPBTModRoot)/mymod.version + $(KSPBT_ModRoot)/mymod.version https://github.com/username/repo/releases/latest/download/mymod.version https://github.com/username.repo/releases/latest @@ -44,7 +44,7 @@ The `include` value can also be set to a json file including any other values yo - $(KSPBTModRoot)/mymod.version + $(KSPBT_ModRoot)/mymod.version ``` \ No newline at end of file diff --git a/docs/msbuild/getting-started.md b/docs/msbuild/getting-started.md index 3863937..31447d2 100644 --- a/docs/msbuild/getting-started.md +++ b/docs/msbuild/getting-started.md @@ -74,9 +74,9 @@ KSPBuildTools needs to know where you have KSP installed in order to reference t There are several options for this. KSPBuildTools will choose in the following order. Either [autodiscovery in the solution directory](#solution-directory) or [setting a reference path in a .user file](#environment-variable) are the recommended methods for most users. -### KSPBTGameRoot MSBuild Property +### KSPBT_GameRoot MSBuild Property -If the {confval}`KSPBTGameRoot` MSBuild property is already set, KSPBuildTools will use it as-is. This can be set in your .csproj.user file. +If the {confval}`KSPBT_GameRoot` MSBuild property is already set, KSPBuildTools will use it as-is. This can be set in your .csproj.user file. ### Environment Variable diff --git a/docs/msbuild/index.md b/docs/msbuild/index.md index 94911d4..04e5588 100644 --- a/docs/msbuild/index.md +++ b/docs/msbuild/index.md @@ -23,6 +23,6 @@ maxdepth: 1 getting-started generating-version-files dependencies -properties +configuration ``` diff --git a/tests/plugin-mod-nuget/plugin-mod-nuget.csproj b/tests/plugin-mod-nuget/plugin-mod-nuget.csproj index 3d60b1d..7290d4d 100644 --- a/tests/plugin-mod-nuget/plugin-mod-nuget.csproj +++ b/tests/plugin-mod-nuget/plugin-mod-nuget.csproj @@ -23,13 +23,13 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginModNuget - $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) + $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) - $(KSPBTGameRoot)/GameData/000_Harmony/0Harmony.dll + $(KSPBT_GameRoot)/GameData/000_Harmony/0Harmony.dll Harmony2 2.2.1.0 False @@ -39,7 +39,7 @@ - $(KSPBTModRoot)/plugin-mod-nuget.version + $(KSPBT_ModRoot)/plugin-mod-nuget.version diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index 57edfbc..6083f33 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -17,13 +17,13 @@ 1701;1702;CS0649;CS1591; 2024 KSPModdingLibs Contributors PluginMod - $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) + $(MSBuildThisFileDirectory)/GameData/$(MSBuildProjectName) - $(KSPBTGameRoot)/GameData/000_Harmony/0Harmony.dll + $(KSPBT_GameRoot)/GameData/000_Harmony/0Harmony.dll Harmony2 2.2.1.0 False @@ -33,7 +33,7 @@ - $(KSPBTModRoot)/plugin-mod.version + $(KSPBT_ModRoot)/plugin-mod.version From 81a8f408c9158cb42dae9456da65e993461052b0 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 20:50:17 -0700 Subject: [PATCH 17/36] fix ckan run target --- KSPCommon.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index f1eeeaf..dfbcedb 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -108,7 +108,7 @@ - + From 65e7e78489949252da5269a6f330b5880cc967d1 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 20:55:59 -0700 Subject: [PATCH 18/36] fix ckan compatibility list in command --- KSPCommon.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index dfbcedb..a4db8af 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -4,7 +4,7 @@ - $(KSPBT_GameRoot)/$(_KSPBT_ManagedRelativePath) + $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) @@ -81,7 +81,7 @@ - <_CKANCompatibleVersionItems Include="$(KSPBT_KSPBT_CKANCompatibleVersions.Split(' '))"/> + <_CKANCompatibleVersionItems Include="$(KSPBT_CKANCompatibleVersions.Split(' '))"/> <_CKANDependency Include="%(Reference.CKANIdentifier)" Condition="'%(Reference.CKANVersion)' == ''"/> <_CKANDependency Include="%(Reference.CKANIdentifier)=%(Reference.CKANVersion)" Condition="'%(Reference.CKANVersion)' != ''"/> <_CKANDependency Include="@(CKANDependency)"/> From 0898ecf8b30b312ffd3d7344fbd963561acd771a Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 21:10:46 -0700 Subject: [PATCH 19/36] oops --- KSPCommon.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index a4db8af..f539370 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -32,7 +32,7 @@ False - + Assembly-CSharp False From b29fd6cfd7b84689830914004c5bb2f7a47a92fd Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 21:20:51 -0700 Subject: [PATCH 20/36] oops 2 --- KSPCommon.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index f539370..1ee8fe5 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -4,7 +4,7 @@ - $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) + $(KSPBT_GameRoot)/$(_KSPBT_ManagedRelativePath) From 159ae132362711404b92823574a06b64bea80b4f Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 21:59:25 -0700 Subject: [PATCH 21/36] try something --- KSPCommon.props | 5 +++++ KSPCommon.targets | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index 9be20b8..7c78c23 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -104,6 +104,11 @@ steam + + + $(KSPBT_GameRoot)/$(_KSPBT_ManagedRelativePath) + + Program diff --git a/KSPCommon.targets b/KSPCommon.targets index 1ee8fe5..6667f48 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -2,11 +2,6 @@ - - - $(KSPBT_GameRoot)/$(_KSPBT_ManagedRelativePath) - - From 9935d48ae5f5a7c03e3e3fec8aff3d7abd84b2b7 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 22:02:47 -0700 Subject: [PATCH 22/36] Try another thing --- .github/actions/compile/action.yml | 2 +- KSPCommon.props | 17 ++++++----------- KSPCommon.targets | 5 +++++ 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index 54b33fe..7d11847 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -76,5 +76,5 @@ runs: working-directory: ${{ inputs.working-directory }} run: | dotnet msbuild -p:Configuration=${{ inputs.build-configuration }} \ - -p:_KSPBT_ManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ + -p:KSPBT_ManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ ${{ runner.debug && '-v:detailed' }} diff --git a/KSPCommon.props b/KSPCommon.props index 7c78c23..2c903b2 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -42,10 +42,10 @@ - - <_KSPBT_ManagedRelativePath Condition=" $([MSBuild]::IsOsPlatform('Windows')) ">KSP_x64_Data/Managed - <_KSPBT_ManagedRelativePath Condition=" $([MSBuild]::IsOsPlatform('OSX')) ">KSP.app/Contents/Resources/Data/Managed - <_KSPBT_ManagedRelativePath Condition=" $([MSBuild]::IsOsPlatform('Linux')) ">KSP_Data/Managed + + KSP_x64_Data/Managed + KSP.app/Contents/Resources/Data/Managed + KSP_Data/Managed @@ -57,7 +57,7 @@ - @@ -70,7 +70,7 @@ - $(_KSPBT_ManagedRelativePath)/Assembly-CSharp.dll + $(KSPBT_ManagedRelativePath)/Assembly-CSharp.dll property @@ -104,11 +104,6 @@ steam - - - $(KSPBT_GameRoot)/$(_KSPBT_ManagedRelativePath) - - Program diff --git a/KSPCommon.targets b/KSPCommon.targets index 6667f48..f539370 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -2,6 +2,11 @@ + + + $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) + + From 899869e5b58e82dc0588795043272cc783e44ab2 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 22:10:53 -0700 Subject: [PATCH 23/36] WHY --- .github/actions/compile/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/compile/action.yml b/.github/actions/compile/action.yml index 7d11847..b86da49 100644 --- a/.github/actions/compile/action.yml +++ b/.github/actions/compile/action.yml @@ -77,4 +77,4 @@ runs: run: | dotnet msbuild -p:Configuration=${{ inputs.build-configuration }} \ -p:KSPBT_ManagedRelativePath=KSP_x64_Data/Managed ${{ inputs.solution-file-path }} \ - ${{ runner.debug && '-v:detailed' }} + ${{ runner.debug && '-v:diagnostic' }} From 13c65770e65711a33fc14dcbe06635a3930e8734 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 22:26:35 -0700 Subject: [PATCH 24/36] OH NO --- KSPCommon.props | 13 ------------- KSPCommon.targets | 13 +++++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index 2c903b2..9073156 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -112,19 +112,6 @@ portable - - - - true - - true - - false - $(KSPBT_ManagedPath) - true - - diff --git a/KSPCommon.targets b/KSPCommon.targets index f539370..bb30073 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -7,6 +7,19 @@ $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) + + + + true + + true + + false + $(KSPBT_ManagedPath) + true + + From d809f3dee49a74078b9fbd882c6b8d248a5cb57a Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 22:32:48 -0700 Subject: [PATCH 25/36] starting to understand this... --- KSPCommon.props | 12 ++++++++++++ KSPCommon.targets | 8 -------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index 9073156..dd8f61e 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -112,6 +112,18 @@ portable + + + + true + + true + + false + true + + diff --git a/KSPCommon.targets b/KSPCommon.targets index bb30073..84370d7 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -9,15 +9,7 @@ - - true - - true - - false $(KSPBT_ManagedPath) - true From ede1af6c4488efe77f7b0411856ed662d2ed8b9e Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 22:56:27 -0700 Subject: [PATCH 26/36] ? --- KSPCommon.targets | 2 ++ 1 file changed, 2 insertions(+) diff --git a/KSPCommon.targets b/KSPCommon.targets index 84370d7..855e2f6 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -7,6 +7,8 @@ $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) + + $(KSPBT_ManagedPath) From 3d9007eb1358ade61024fe733e34442abc9d01a1 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 23:00:49 -0700 Subject: [PATCH 27/36] can I do this now? --- KSPCommon.props | 9 +-------- KSPCommon.targets | 8 ++++++++ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index dd8f61e..a3fafba 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -114,14 +114,7 @@ - - true - - true - - false - true + diff --git a/KSPCommon.targets b/KSPCommon.targets index 855e2f6..c710c8f 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -11,6 +11,14 @@ + + true + + true + + false + true $(KSPBT_ManagedPath) From 1a2a80b48e1385556f8342b3356efeb0099e58a8 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 23:17:44 -0700 Subject: [PATCH 28/36] this might be cleaner? --- KSPCommon.props | 5 ----- KSPCommon.targets | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index a3fafba..9073156 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -112,11 +112,6 @@ portable - - - - - diff --git a/KSPCommon.targets b/KSPCommon.targets index c710c8f..e57aa7d 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -7,8 +7,6 @@ $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) - - @@ -20,6 +18,8 @@ false true $(KSPBT_ManagedPath) + <_FullFrameworkReferenceAssemblyPaths>$(KSPBT_ManagedPath) + <_TargetFrameworkDirectories>$(KSPBT_ManagedPath) From 0b822698bb301bdcf5fc641124b2427b2efa40a4 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Sun, 20 Jul 2025 23:28:18 -0700 Subject: [PATCH 29/36] Try it out on more dotnet versions --- .github/workflows/internal-test-plugin-nuget.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/internal-test-plugin-nuget.yml b/.github/workflows/internal-test-plugin-nuget.yml index ffbedbc..d3dbbc5 100644 --- a/.github/workflows/internal-test-plugin-nuget.yml +++ b/.github/workflows/internal-test-plugin-nuget.yml @@ -13,7 +13,11 @@ env: NuGetDirectory: ${{ github.workspace}}/nuget jobs: + build: + strategy: + matrix: + dotnet-version: [ 5.x, 7.x, 9.x ] runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 @@ -40,10 +44,11 @@ jobs: ksp-zip-url: https://github.com/KSPModdingLibs/KSPLibs/raw/main/KSP-1.12.5.zip working-directory: ${{ env.TESTDIR }} solution-file-path: plugin-mod-nuget.csproj + dotnet-version: ${{ matrix.dotnet-version }} env: KSPBuildToolsVersion: ${{ inputs.package-version }} - uses: ./.github/actions/assemble-release with: artifacts: ${{ env.TESTDIR }}/GameData - output-file-name: plugin-mod-nuget + output-file-name: plugin-mod-nuget-${{ matrix.dotnet-version }} From cf333d246b0b33b8feae2b333a8363a40a855f69 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 21 Jul 2025 22:39:47 -0700 Subject: [PATCH 30/36] move the last of the GameRoot logic to targets This means that everything can be set in .csproj.user without hacks --- KSPCommon.props | 49 ----------------------------------------------- KSPCommon.targets | 45 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index 9073156..3df599f 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -56,11 +56,6 @@ <_KSPBT_SteamGameRoot Condition=" $([MSBuild]::IsOsPlatform('OSX')) ">$(HOME)/Library/Application Support/Steam/steamapps/common/Kerbal Space Program - - - - @@ -68,50 +63,6 @@ - - - $(KSPBT_ManagedRelativePath)/Assembly-CSharp.dll - property - - - - - - $(KSP_ROOT) - environment variable - - - - - - - - - - $(SolutionDir)KSP - solution directory - - - - - $(ReferencePath) - reference path - - - - - $(_KSPBT_SteamGameRoot) - steam - - - - - Program - $(KSPBT_GameRoot)/$(_KSPBT_GameExecutable) - $(KSPBT_GameRoot) - portable - - diff --git a/KSPCommon.targets b/KSPCommon.targets index e57aa7d..efdf8b2 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -2,6 +2,51 @@ + + + $(KSPBT_ManagedRelativePath)/Assembly-CSharp.dll + property + + + + + + $(KSP_ROOT) + environment variable + + + + + + + + + + $(SolutionDir)KSP + solution directory + + + + + $(ReferencePath) + reference path + + + + + $(_KSPBT_SteamGameRoot) + steam + + + + + Program + $(KSPBT_GameRoot)/$(_KSPBT_GameExecutable) + $(KSPBT_GameRoot) + portable + + + $(KSPBT_GameRoot)/$(KSPBT_ManagedRelativePath) From a58bf431541ddd1aab6fa5804d0de27e21b8b54b Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 21 Jul 2025 23:29:42 -0700 Subject: [PATCH 31/36] Fix target dependency chain --- KSPCommon.targets | 70 ++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 37 deletions(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index efdf8b2..258f6aa 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -103,12 +103,6 @@ - - - - - - - - + + + KSPBT_ReferenceModAssemblies;$(ResolveAssemblyReferencesDependsOn) + KSPBT_ReferenceModAssemblies;$(KSPBT_GenerateCKANScriptDependsOn) + + - <_BinariesToCopy Include="$(TargetDir)/**/*.dll"/> - <_BinariesToCopy Include="$(TargetDir)/**/*.pdb" Condition="'$(Condition)' == 'Debug'"/> + + %(ModReference.identity) + - - + + <_CKANScript>$(BaseIntermediateOutputPath)ckancommands.cache - + <_CKANCompatibleVersionItems Include="$(KSPBT_CKANCompatibleVersions.Split(' '))"/> <_CKANDependency Include="%(Reference.CKANIdentifier)" Condition="'%(Reference.CKANVersion)' == ''"/> @@ -162,9 +167,9 @@ - - - + + KSPBT_InstallCKANDependencies;$(ResolveAssemblyReferencesDependsOn) + @@ -175,26 +180,6 @@ - - - - - - - - %(ModReference.identity) - - - - @@ -309,4 +294,15 @@ + + + + + <_BinariesToCopy Include="$(TargetDir)/**/*.dll"/> + <_BinariesToCopy Include="$(TargetDir)/**/*.pdb" Condition="'$(Condition)' == 'Debug'"/> + + + + From 72e8819cbcb2176c0da8eab2e162056d1bf81594 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Mon, 21 Jul 2025 23:42:38 -0700 Subject: [PATCH 32/36] Move tests to ModReferences and recommend not using KSPBT_GameRoot in csproj --- docs/msbuild/configuration.md | 13 ++++++++----- tests/plugin-mod-nuget/plugin-mod-nuget.csproj | 6 +++--- tests/plugin-mod/plugin-mod.csproj | 11 +++++++---- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/docs/msbuild/configuration.md b/docs/msbuild/configuration.md index db02c9e..75b2fd9 100644 --- a/docs/msbuild/configuration.md +++ b/docs/msbuild/configuration.md @@ -1,11 +1,7 @@ -# MSBuild Items And Properties +# Configuration ## Properties -```{confval} KSPBT_GameRoot -This property should be set to the root directory of your KSP install. You should not set this in your csproj, see [Locating your KSP Install](getting-started.md/#locating-your-ksp-install) -``` - ```{confval} KSPBT_ModRoot --- default: `$(MSBuildProjectDir)/../GameData/$(MSBuildProjectName)/` @@ -71,3 +67,10 @@ default: `true` --- If set to `true`, adds references to the assemblies included in `ModReference` list. ``` + +````{confval} KSPBT_GameRoot +```{warning} +You should **not** set or use this property in your csproj file. +``` +This property should be set to the root directory of your KSP install. see [Locating your KSP Install](getting-started.md/#locating-your-ksp-install) +```` diff --git a/tests/plugin-mod-nuget/plugin-mod-nuget.csproj b/tests/plugin-mod-nuget/plugin-mod-nuget.csproj index 7290d4d..021b63b 100644 --- a/tests/plugin-mod-nuget/plugin-mod-nuget.csproj +++ b/tests/plugin-mod-nuget/plugin-mod-nuget.csproj @@ -28,12 +28,12 @@ - - $(KSPBT_GameRoot)/GameData/000_Harmony/0Harmony.dll + + GameData/000_Harmony/0Harmony.dll Harmony2 2.2.1.0 False - + diff --git a/tests/plugin-mod/plugin-mod.csproj b/tests/plugin-mod/plugin-mod.csproj index 6083f33..490ed3b 100644 --- a/tests/plugin-mod/plugin-mod.csproj +++ b/tests/plugin-mod/plugin-mod.csproj @@ -6,6 +6,10 @@ all runtime; build; native; contentfiles; analyzers + + all + runtime; build; native; contentfiles; analyzers + @@ -22,12 +26,11 @@ - - $(KSPBT_GameRoot)/GameData/000_Harmony/0Harmony.dll + + GameData/000_Harmony/0Harmony.dll Harmony2 2.2.1.0 - False - + From 105cc15d7baf65654a84ca62db0345a62e3c5253 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Wed, 23 Jul 2025 22:17:02 -0700 Subject: [PATCH 33/36] Make the stdlib avoidance thing conditional --- KSPCommon.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KSPCommon.targets b/KSPCommon.targets index 258f6aa..582ff86 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -53,7 +53,7 @@ - + true From b08da4ab8b1abe27cb3ecdfae7497d12ef4c7fe8 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Wed, 23 Jul 2025 23:43:33 -0700 Subject: [PATCH 34/36] Add default settings for the `Unity` configuration For building for use in the unity editor, handy for UIs! --- KSPCommon.props | 39 ++++++++++++++++++++++++++++++++------- KSPCommon.targets | 8 +------- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index 3df599f..63d2051 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -4,7 +4,27 @@ true - + + + + false + false + + + false + + + false + false + + + false + + + false + + + $(MSBuildProjectDirectory)/../GameData/$(MSBuildProjectName)/ @@ -15,30 +35,35 @@ 1.12 1.11 1.10 1.9 1.8 - + true true true true - + true - true - + true - true + + true true - + false + + 1.12 + 1.8 + 1.12 + diff --git a/KSPCommon.targets b/KSPCommon.targets index 582ff86..62375cd 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -243,13 +243,7 @@ - - - 1.12 - 1.8 - 1.12 - - + Date: Wed, 23 Jul 2025 23:44:04 -0700 Subject: [PATCH 35/36] Write more docs All properties and most items are now documented. dependencies page now recommends using `ModReference` --- docs/msbuild/configuration.md | 131 +++++++++++++++++++++++++++++----- docs/msbuild/dependencies.md | 45 +++++------- 2 files changed, 133 insertions(+), 43 deletions(-) diff --git a/docs/msbuild/configuration.md b/docs/msbuild/configuration.md index 75b2fd9..9626663 100644 --- a/docs/msbuild/configuration.md +++ b/docs/msbuild/configuration.md @@ -26,20 +26,6 @@ default: `1.12 1.11 1.10 1.9 1.8` Used by the `CKANInstall` target to set additional KSP versions to treat as compatible when installing ``` -```{confval} KSPBT_GenerateAssemblyAttribute ---- -default: `true` ---- -If set to `true`, automatically generates the `KSPAssembly` for your assembly from the `Version` property. -``` - -```{confval} KSPBT_GenerateDependencyAttributes ---- -default: `true` ---- -If set to `true`, automatically generates `KSPAssemblyDependency` attributes for each dependency. Dependencies should have either the `CKANIdentifier` metadata or `KSPAssemblyName` metadata. Versions can be supplied with `CKANVersion` or `KSPAssemblyVersion`. -``` - ```{confval} KSPBT_ReferenceSystemAssemblies --- default: `true` @@ -56,21 +42,134 @@ If set to `true`, adds assembly references to all UnityEngine assemblies in the ```{confval} KSPBT_ReferenceGameAssemblies --- -default: `true` +default: `true`, except in the `Unity` configuration --- If set to `true`, adds references to Assembly-CSharp and Assembly-CSharp-firstpass assemblies from the KSP install. ``` ```{confval} KSPBT_ReferenceModAssemblies --- -default: `true` +default: `true`, except in the `Unity` configuration --- If set to `true`, adds references to the assemblies included in `ModReference` list. ``` +```{confval} KSPBT_GenerateAssemblyAttribute +--- +default: `true`, except in the `Unity` configuration +--- +If set to `true`, automatically generates the `KSPAssembly` for your assembly from the `Version` property. +``` + +```{confval} KSPBT_GenerateDependencyAttributes +--- +default: `true`, except in the `Unity` configuration +--- +If set to `true`, automatically generates `KSPAssemblyDependency` attributes for each dependency. Dependencies should have either the `CKANIdentifier` metadata or `KSPAssemblyName` metadata. Versions can be supplied with `CKANVersion` or `KSPAssemblyVersion`. +``` + +```{confval} KSPBT_CopyDLLsToPluginFolder +--- +default: `true`, except in the `Unity` configuration +--- +If set to `true`, automatically copies the compiled DLL to the {confval}`KSPBT_ModPluginFolder`. +``` + +```{confval} KSPBT_GenerateVersionFile +--- +default: `true`, except in the `Unity` configuration +--- +If set to `true`, automatically generates a version file using the information in any {confval}`KSPVersionFile` items. Without defining a {confval}`KSPVersionFile`, nothing will be generated. See [](generating-version-files.md/) for more details. +``` + ````{confval} KSPBT_GameRoot ```{warning} You should **not** set or use this property in your csproj file. ``` This property should be set to the root directory of your KSP install. see [Locating your KSP Install](getting-started.md/#locating-your-ksp-install) ```` + +## Items + +````{confval} ModReference +A reference to another mod that is a dependency. This mod will be automatically referenced in the build process and installed using CKAN if an identifier is given. See [](dependencies.md) for examples. + +```{rubric} Metadata +``` + +```{describe} Identity +The name of the mod you are referencing, as set in that mod's `KSPAssemblyAttribute` +``` + +```{describe} DLLPath +The path of the mod's assembly to reference when building, relative to {confval}`KSPBT_GameRoot`. +``` + +```{describe} CKANIdentifier +The name of the mod in CKAN to install before building. +``` + +```{describe} CKANVersion +The specific version to install from CKAN, if any. +``` + +Any additional metadata is copied to the resulting [`Reference`](https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022#reference) item +```` + +````{confval} KSPVersionFile +Defines a version file to generate. See [](generating-version-files.md) for examples. + +```{rubric} Metadata +``` + +```{describe} Identity +To create a new version file from scratch, set to `.`. Otherwise set to a path to a json version file to use as a base +``` +```{describe} Destination +Path to where the generated json version file should be placed +``` + +```{confval} Name +--- +default: `$(ProjectName)` +--- +The mod name. Corresponds to the `NAME` value in json. +``` + +```{confval} Version +--- +default: `$(FileVersion)` +--- +The mod version. Corresponds with the `VERSION` value in json. +``` + +```{describe} URL +The URL of the remote version file. Corresponds with the `URL` value in json. +``` + +```{describe} Download +Where to link players to update your mod. Corresponds with the `DOWNLOAD` value in json. +``` + +```{confval} KSP_Version +--- +default: `1.12` +--- +The KSP version the mod is targeting. Corresponds with the `KSP_VERSION` value in json. +``` + +```{confval} KSP_Version_Min +--- +default: `1.8` +--- +The minimum supported KSP version. Corresponds with the `KSP_VERSION_MIN` value in json. +``` + +```{confval} KSP_Version_Max +--- +default: `1.12` +--- +The maximum supported KSP version. Corresponds with the `KSP_VERSION_MAX` value in json. +``` + +```` diff --git a/docs/msbuild/dependencies.md b/docs/msbuild/dependencies.md index 9a5abed..6241621 100644 --- a/docs/msbuild/dependencies.md +++ b/docs/msbuild/dependencies.md @@ -4,33 +4,31 @@ KSPBuildTools can help manage other mods that you depend on ## Referencing Dependency DLLs -Mod DLLs should be referenced as with any other DLLs, like so. See [the Microsoft docs on Reference items](https://learn.microsoft.com/en-us/visualstudio/msbuild/common-msbuild-project-items?view=vs-2022#reference) for more info. Make sure that `False`{l=xml} is set or the DLL will be copied to your output directory. +Mod DLLs should be referenced with the {confval}`ModReference` item, like so. -the {confval}`KSPBT_GameRoot` property can be used to reference the KSP install wherever it is. ```xml - - False - - - $(KSPBT_GameRoot)/GameData/000_Harmony/0Harmony.dll - False - + + GameData/Modulemanager*.dll + + + GameData/000_Harmony/0Harmony.dll + ``` ## Installing Dependencies Automatically -KSPBuildTools can install CKAN mods automatically when built. This is useful for CI workflows such as those using the {gha:action}`compile` action, or to make it easier for others to compile your mod themselves. Either add the `` metadata to your `` items, or if the dependency mod doesn't have a dll you need to reference you can use the `` item. +KSPBuildTools can install CKAN mods automatically when built. This is useful for CI workflows such as those using the {gha:action}`compile` action, or to make it easier for others to compile your mod themselves. Either add the `` metadata to your `` items, or if the dependency mod doesn't have a dll you need to reference you can use the `` item. ```xml - - False + + GameData/Modulemanager*.dll ModuleManager - + @@ -42,11 +40,11 @@ You can also mark explicit versions to install. ```xml - - False + + GameData/Modulemanager*.dll ModuleManager 4.2.3 - + @@ -59,26 +57,19 @@ KSP mods should mark their dependency DLLs using the `KSPAssemblyDependency` att `[assembly: KSPAssemblyDependency("0Harmony", 0, 0, 0)]`{l=csharp} -If the {confval}`KSPBT_GenerateDependencyAttributes` property is set to `true`, KSPBuildTools will generate these attributes automatically. It uses any `Reference` item that has a `` or `` metadata value. +If the {confval}`KSPBT_GenerateDependencyAttributes` property is set to `true` (the default), KSPBuildTools will generate these attributes automatically. -The assembly name is set to the `` metadata value, and falls back to the `` metadata value. +The assembly name is taken from the value of the item. The version is taken from the `` metadata value, however leaving it at the default of 0.0.0 is usually acceptable ```xml - - False + + GameData/TweakScale/plugins/Scale.dll TweakScaleRescaled - Scale 3.2.0 - - - - true - true - ``` \ No newline at end of file From 7ec5f4dda75b5cef6af6ec1b37a6647f77439f17 Mon Sep 17 00:00:00 2001 From: Andrew Cassidy Date: Tue, 5 Aug 2025 22:43:40 -0700 Subject: [PATCH 36/36] Allow per-dependency disabling of attribute generation --- KSPCommon.props | 1 + KSPCommon.targets | 4 ++-- docs/msbuild/dependencies.md | 17 +++++++++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/KSPCommon.props b/KSPCommon.props index 63d2051..4cbfe17 100644 --- a/KSPCommon.props +++ b/KSPCommon.props @@ -58,6 +58,7 @@ false + true 1.12 diff --git a/KSPCommon.targets b/KSPCommon.targets index 62375cd..257da3c 100644 --- a/KSPCommon.targets +++ b/KSPCommon.targets @@ -133,7 +133,7 @@ Condition=" '$(KSPBT_ReferenceModAssemblies)' == 'true' "> - %(ModReference.identity) + %(ModReference.identity) @@ -208,7 +208,7 @@ - + $([System.String]::Copy('%(Reference.identity)').Split(',')[0]) %(Reference.CKANVersion) 0.0 diff --git a/docs/msbuild/dependencies.md b/docs/msbuild/dependencies.md index 6241621..064c723 100644 --- a/docs/msbuild/dependencies.md +++ b/docs/msbuild/dependencies.md @@ -66,10 +66,23 @@ The version is taken from the `` metadata value, however lea ```xml - + GameData/TweakScale/plugins/Scale.dll TweakScaleRescaled 3.2.0 - + + +``` + +To disable generating the `KSPAssemblyDependency` attribute for a single dependency (for example, if it lacks the `KSPAssembly` attribute), you can set `GenerateDependencyAttribute` to false + +```xml + + + + GameData/TweakScale/plugins/Scale.dll + TweakScaleRescaled + false + ``` \ No newline at end of file