Skip to content

Commit

Permalink
Update README build instructions, compiler version and post-build
Browse files Browse the repository at this point in the history
Compiler updated to 3.6
Post-build now copy all the required files
  • Loading branch information
sarbian committed Jul 5, 2020
1 parent 2aaeffe commit 487741a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 20 deletions.
10 changes: 4 additions & 6 deletions MechJeb2/MechJeb2.csproj
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.Net.Compilers.3.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.3.4.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.3.6.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.3.6.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -253,8 +253,6 @@
</Reference>
<Reference Include="System.Core">
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL" />
<Reference Include="netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" />
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
</Reference>
Expand Down Expand Up @@ -291,14 +289,14 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">call "$(ProjectDir)copy_build.bat" "$(TargetPath)" "$(TargetDir)" "$(TargetName)"</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">sh -c "TARGET_PATH='$(TargetPath)' TARGET_DIR='$(TargetDir)' TARGET_NAME='$(TargetName)' sh '$(ProjectDir)/copy_build.sh'"</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">call "$(ProjectDir)copy_build.bat" "$(TargetPath)" "$(TargetDir)" "$(TargetName)" "$(ProjectDir)"</PostBuildEvent>
<PostBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">sh -c "TARGET_PATH='$(TargetPath)' TARGET_DIR='$(TargetDir)' TARGET_NAME='$(TargetName)' PROJECT_DIR='$(ProjectDir)' sh '$(ProjectDir)/copy_build.sh'"</PostBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.3.4.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.3.4.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.3.6.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.3.6.0\build\Microsoft.Net.Compilers.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
22 changes: 11 additions & 11 deletions MechJeb2/copy_build.bat
@@ -1,12 +1,14 @@

IF NOT DEFINED MONO echo MONO env variable not defined
IF NOT DEFINED PDB2MDB echo PDB2MDB env variable not defined
IF NOT DEFINED KSPDIR echo KSPDIR env variable not defined

SET TargetPath=%1
SET TargetDir=%2
SET TargetName=%3
SET ProjectDir=%4

echo %TargetPath% %TargetDir% %TargetName%
echo %TargetPath% %TargetDir% %TargetName% %ProjectDir%

IF NOT EXIST "%MONO%" (
echo Expected "%MONO%" to point to mono.exe
Expand All @@ -24,14 +26,12 @@ IF NOT EXIST %KSPDIR%\* (
exit 0
)

IF NOT EXIST %KSPDIR%\GameData\MechJeb2\Plugins\* (
echo Expected "%KSPDIR%" to contain a GameData\MechJeb2\Plugins subdirectory but it does not'
exit 1
)

echo Copying to "%KSPDIR%"
IF EXIST "%TargetPath%" xcopy /Y "%TargetPath%" "%KSPDIR%\GameData\MechJeb2\Plugins\"
IF EXIST "%TargetDir%%TargetName%.pdb" xcopy /Y "%TargetDir%%TargetName%.pdb" "%KSPDIR%\GameData\MechJeb2\Plugins\"
IF EXIST "%TargetDir%%TargetName%.dll.mdb" xcopy /Y "%TargetDir%%TargetName%.dll.mdb" "%KSPDIR%\GameData\MechJeb2\Plugins\"


IF EXIST "%TargetPath%" xcopy /Y /I "%TargetPath%" "%KSPDIR%\GameData\MechJeb2\Plugins\"
IF EXIST "%TargetDir%%TargetName%.pdb" xcopy /Y /I "%TargetDir%%TargetName%.pdb" "%KSPDIR%\GameData\MechJeb2\Plugins\"
IF EXIST "%TargetDir%%TargetName%.dll.mdb" xcopy /Y /I "%TargetDir%%TargetName%.dll.mdb" "%KSPDIR%\GameData\MechJeb2\Plugins\"

IF EXIST "%ProjectDir%..\Bundles" xcopy /S /Y /I "%ProjectDir%..\Bundles" "%KSPDIR%\GameData\MechJeb2\Bundles"
IF EXIST "%ProjectDir%..\Icons" xcopy /S /Y /I "%ProjectDir%..\Icons" "%KSPDIR%\GameData\MechJeb2\Icons"
IF EXIST "%ProjectDir%..\Localization" xcopy /S /Y /I "%ProjectDir%..\Localization" "%KSPDIR%\GameData\MechJeb2\Localization"
IF EXIST "%ProjectDir%..\Parts" xcopy /S /Y /I "%ProjectDir%..\Parts" "%KSPDIR%\GameData\MechJeb2\Parts"
12 changes: 10 additions & 2 deletions MechJeb2/copy_build.sh
Expand Up @@ -19,6 +19,11 @@ if [ -z "${TARGET_NAME}" ] ; then
exit 1
fi

if [ -z "${PROJECT_DIR}" ] ; then
echo 'Expected PROJECT_DIR to be defined but it is not' >&2
exit 1
fi

if [ -z "${PDB2MDB}" ] ; then
echo '$PDB2MDB not found'
else
Expand All @@ -34,11 +39,14 @@ else
exit 1
fi
if ! [ -d "${KSPDIR}/GameData/MechJeb2/Plugins" ] ; then
echo 'Expected $KSPDIR to contain a GameData/MechJeb2/Plugins subdirectory but it does not' >&2
exit 1
mkdir -p "${KSPDIR}/GameData/MechJeb2/Plugins/"
fi
echo "Copying to '${KSPDIR}'"
cp "${TARGET_PATH}" "${KSPDIR}/GameData/MechJeb2/Plugins/"
test -f "${TARGET_DIR}/${TARGET_NAME}.pdb" && cp "${TARGET_DIR}/${TARGET_NAME}.pdb" "${KSPDIR}/GameData/MechJeb2/Plugins/"
test -f "${TARGET_DIR}/${TARGET_NAME}.dll.mdb" && cp "${TARGET_DIR}/${TARGET_NAME}.dll.mdb" "${KSPDIR}/GameData/MechJeb2/Plugins/"
cp -r ${PROJECT_DIR}/../Bundles "${KSPDIR}/GameData/MechJeb2/"
cp -r ${PROJECT_DIR}/../Icons "${KSPDIR}/GameData/MechJeb2/"
cp -r ${PROJECT_DIR}/../Localization "${KSPDIR}/GameData/MechJeb2/"
cp -r ${PROJECT_DIR}/../Parts "${KSPDIR}/GameData/MechJeb2/"
fi
2 changes: 1 addition & 1 deletion MechJeb2/packages.config
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Net.Compilers" version="3.4.0" targetFramework="net47" developmentDependency="true" />
<package id="Microsoft.Net.Compilers" version="3.6.0" targetFramework="net47" developmentDependency="true" />
</packages>
14 changes: 14 additions & 0 deletions README.md
Expand Up @@ -35,7 +35,9 @@ Unzip the zip in KSP GameData directory. You should have something that looks li
Kerbal Space Program
-- GameData
-- MechJeb2
-- Bundles
-- Icons
-- Localization
-- Parts
-- Plugins

Expand All @@ -56,6 +58,7 @@ If you want the unstable dev version of MechJeb then :

## Build

### Linux
The project uses Mono and Make to build the addon, make sure you have both installed.

1. (optional) Set your KSP directory
Expand All @@ -76,11 +79,22 @@ The project uses Mono and Make to build the addon, make sure you have both insta
make install
```

### Windows

1. Install the version of Unity that KSP uses ( Currently 2019.2.2f1 )
2. Configure your system environement variables and add:
- KSPDIR set to where your KSP install is ( usually C:\Program Files\Steam (x86)\SteamApps\Common\Kerbal Space Program )
- MONO set to the path of Unity current mono.exe ( usually C:\Program Files\Unity\Hub\Editor\2019.2.2f1\Editor\Data\MonoBleedingEdge\bin\mono.exe )
- PDB2MDB set to the path of pdb2mdb.exe ( usually C:\Program Files\Unity\Hub\Editor\2019.2.2f1\Editor\Data\MonoBleedingEdge\lib\mono\4.5\pdb2mdb.exe )
3. Load MechJeb2.sln and open the properties of the MechJeb2 project (Right-Click=>properties). In the "Reference Path" section add the KSP libs folder to the list ( usually C:\Program Files\Steam (x86)\SteamApps\Common\Kerbal Space Program\KSP_x64_Data\Managed\ )

## Maintainer

[@sarbian](https://github.com/sarbian)

[@lamont-granquist](https://github.com/lamont-granquist)



## License

Expand Down

0 comments on commit 487741a

Please sign in to comment.