From 86a64e00b2218dc4df6491c1386f7dedacc36479 Mon Sep 17 00:00:00 2001 From: Evan Hemsley Date: Tue, 3 Mar 2020 16:03:33 -0800 Subject: [PATCH] readme + first pass on install script --- README.md | 27 +++++++++++++++ fnalibs/README.md | 4 --- install.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 4 deletions(-) create mode 100644 README.md delete mode 100644 fnalibs/README.md create mode 100644 install.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..ac63a5a --- /dev/null +++ b/README.md @@ -0,0 +1,27 @@ +# FNA-VSCode-Template + +Template and build tasks for developing a cross-platform multi-target .NET Framework and .NET Core FNA project in VSCode. + +## Features + +- Includes project boilerplate code +- Build tasks for both .NET Framework and .NET Core side by side +- Press F5 to build and debug in-editor with Core Debugger + +## Requirements + +- Git +- [Visual Studio Code](https://code.visualstudio.com/) +- [VSCode C# Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp) +- [.NET Core SDK](https://dotnet.microsoft.com/download/dotnet-core) +- [.NET Framework SDK](https://dotnet.microsoft.com/download/visual-studio-sdks) or [Mono](https://www.mono-project.com/) + + +## Installation + +- Download this repository +- Run `install.sh` if you are on Linux/OSX or `install.ps1` if you are on Windows and follow the instructions + +## Acknowledgments + +Thanks to Andrew Russell and Caleb Cornett's FNA templates for a starting point for this template. diff --git a/fnalibs/README.md b/fnalibs/README.md deleted file mode 100644 index 456bb06..0000000 --- a/fnalibs/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Put your fnalibs here. - -If you don't have fnalibs, the link is located on this wiki page: -https://github.com/FNA-XNA/FNA/wiki/1:-Download-and-Update-FNA diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e0ed1a5 --- /dev/null +++ b/install.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# Author: Evan Hemsley +# Usage: ./install.sh + +# This file is heavily borrowed from Caleb Cornett's template install script. + +# Get the directory of this script +MY_DIR=$(dirname "$BASH_SOURCE") + +# Checks if git is installed +function checkGit() +{ + git --version > /dev/null 2>&1 + if [ ! $? -eq 0 ]; then + echo >&2 "ERROR: Git is not installed. Please install git to download FNA." + exit 1 + fi +} + +# Pulls FNA from the git master branch +function pullFNA() +{ + checkGit + echo "Updating to the latest git version of FNA..." + git submodule update --init --recursive + if [ $? -eq 0 ]; then + echo "Finished updating!" + else + echo >&2 "ERROR: Unable to update." + exit 1 + fi +} + +# Downloads and extracts prepackaged archive of native libraries ("fnalibs") +function getLibs() +{ + # Downloading + echo "Downloading latest fnalibs..." + curl http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 > "$MY_DIR/fnalibs.tar.bz2" + if [ $? -eq 0 ]; then + echo "Finished downloading!" + else + >&2 echo "ERROR: Unable to download successfully." + exit 1 + fi + + # Decompressing + echo "Decompressing fnalibs..." + mkdir -p $MY_DIR/fnalibs + tar xjC $MY_DIR/fnalibs -f $MY_DIR/fnalibs.tar.bz2 + if [ $? -eq 0 ]; then + echo "Finished decompressing!" + echo "" + rm $MY_DIR/fnalibs.tar.bz2 + else + >&2 echo "ERROR: Unable to decompress successfully." + exit 1 + fi +} + +getLibs + +read -p "Enter the project name to use for your folder and csproj file or 'exit' to quit: " newProjectName +if [[ $newProjectName = 'exit' || -z "$newProjectName" ]]; then + exit 1 +fi + +# copy everything into new dir +cd .. +NEW_PROJECT_DIR=$(pwd "./${newProjectName}") +cp -R $MY_DIR $NEW_PROJECT_DIR + +cd $NEW_PROJECT_DIR +files=(ProjectName.Core.sln ProjectName.Framework.sln .gitignore ProjectName/ProjectName.Core.csproj ProjectName/ProjectName.Framework.csproj ProjectName/ProjectNameGame.cs ProjectName/Program.cs .vscode/tasks.json .vscode/launch.json) +for file in "${files[@]}"; do + sed -i '' "s/ProjectName/$newProjectName/g" $file +done + +mv ProjectName.Core.sln "$newProjectName.Core.sln" +mv ProjectName.Framework.sln "$newProjectName.Framework.sln" +mv ProjectName/ProjectName.Core.csproj "ProjectName/$newProjectName.Core.csproj" +mv ProjectName/ProjectName.Framework.csproj "ProjectName/$newProjectName.Framework.csproj" +mv ProjectName/ProjectNameGame.cs ProjectName/${newProjectName}Game.cs +mv ProjectName "$newProjectName"