Skip to content

Commit

Permalink
Use KSPBuildTools from nuget
Browse files Browse the repository at this point in the history
  • Loading branch information
drewcassidy committed Sep 3, 2024
1 parent e96eda5 commit 72e85fe
Showing 1 changed file with 19 additions and 41 deletions.
60 changes: 19 additions & 41 deletions Source/Shabby.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="KSPBuildTools" Version="0.0.0-*" />
</ItemGroup>

<!-- Static Properties -->
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<LangVersion>7.3</LangVersion>
<IsPackable>false</IsPackable>
<PlatformTarget>x64</PlatformTarget>
<NoWarn>1701;1702;CS0649;CS1591</NoWarn>
<NoWarn>1701;1702;CS0649;CS1591;</NoWarn>
<AssemblyCopyright>2024 KSPModdingLibs Contributors</AssemblyCopyright>
<AssemblyName>Shabby</AssemblyName>
<GenerateAssemblyVersionAttribute>False</GenerateAssemblyVersionAttribute>
<RepoRootPath>$(ProjectDir)../</RepoRootPath>
<StagingGameData></StagingGameData>
</PropertyGroup>
Expand All @@ -20,6 +23,12 @@
<Reference Include="0Harmony, Culture=neutral, PublicKeyToken=null">
<HintPath>$(KSPRoot)/GameData/000_Harmony/0Harmony.dll</HintPath>
<CKANIdentifier>Harmony2</CKANIdentifier>
<CKANVersion>2.2.1.0</CKANVersion>
<Private>False</Private>
</Reference>
<Reference Include="0Harmony, Culture=neutral, PublicKeyToken=null">
<HintPath>$(KSPRoot)/GameData/000_Harmony/0Harmony.dll</HintPath>
<CKANIdentifier>ModuleManager</CKANIdentifier>
<Private>False</Private>
</Reference>
</ItemGroup>
Expand All @@ -30,47 +39,16 @@
<Destination>$(RepoRootPath)GameData/Shabby/Shabby.version</Destination>
</VersionFile>
</ItemGroup>

<!-- Target to get information about the git repo -->
<Target Name="GetVersionInfo" BeforeTargets="BeforeBuild">
<Exec Command="git describe --tags --abbrev=0" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="RepoLatestTag"/>
</Exec>
<Exec Command="git rev-list $(RepoLatestTag)..HEAD --count" ConsoleToMSBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="RepoTagDistance"/>
</Exec>

<!-- Infer the current version from this information -->
<PropertyGroup>
<VersionMajor>$(RepoLatestTag.Split('.')[0])</VersionMajor>
<VersionMinor>$(RepoLatestTag.Split('.')[1])</VersionMinor>
<VersionPatch>$(RepoLatestTag.Split('.')[2])</VersionPatch>
<VersionPatch Condition="$(RepoTagDistance) != '0'">$([MSBuild]::Add($(VersionPatch), 1))</VersionPatch>
<Build>$(RepoTagDistance)</Build>
<Version>$(VersionMajor).$(VersionMinor).$(VersionPatch)</Version>
</PropertyGroup>

<!-- Write this information to the AssemblyInfo.cs file -->
<!-- This cant go under <Project> because then it would become static and not reflect the information above -->
<ItemGroup>
<AssemblyAttribute Include="KSPAssembly">
<_Parameter1>$(AssemblyName)</_Parameter1>
<_Parameter2_IsLiteral>true</_Parameter2_IsLiteral>
<_Parameter2>$(VersionMajor)</_Parameter2>
<_Parameter3_IsLiteral>true</_Parameter3_IsLiteral>
<_Parameter3>$(VersionMinor)</_Parameter3>
<_Parameter4_IsLiteral>true</_Parameter4_IsLiteral>
<_Parameter4>$(VersionPatch)</_Parameter4>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Reflection.AssemblyVersionAttribute">
<_Parameter1>$(Version).$(Build)</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
</Target>


<PropertyGroup>
<GetVersionFromGit>true</GetVersionFromGit>
<GenerateKSPAssemblyAttribute>true</GenerateKSPAssemblyAttribute>
<GenerateKSPAssemblyDependencyAttributes>true</GenerateKSPAssemblyDependencyAttributes>
</PropertyGroup>

<Target Name="MakeModDir" BeforeTargets="BeforeBuild">
<MakeDir Directories="$(RepoRootPath)GameData/Shabby" />
</Target>

<Import Project="$(ProjectDir)../KSPBuildTools/KSPCommon.targets" />
<!-- <Import Project="$(ProjectDir)../KSPBuildTools/KSPCommon.targets" />-->
</Project>

0 comments on commit 72e85fe

Please sign in to comment.