diff --git a/.vscode/buildEffects.ps1 b/.vscode/buildEffects.ps1 new file mode 100644 index 0000000..23bf379 --- /dev/null +++ b/.vscode/buildEffects.ps1 @@ -0,0 +1,23 @@ +#!/bin/bash +# buildEffects +# Compiles all .fx files found in the project's Content directory. +# Intended for usage with VS Code Build Tasks tooling. +# You may need to change the path to fxc.exe depending on your installation. + +Write-Output "Starting build process..." + +Set-Location ../project_name + +$fxc = "C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)\Utilities\bin\x86\fxc.exe" + +$files = Get-ChildItem -Path "Content\*" -Include *fx + +foreach ($file in $files) +{ + $fileName = $file.BaseName + $filePath = $file.FullName + & $fxc /T fx_2_0 $filePath /Fo "${filePath}b" + + Write-Output "Built ${fileName}.fx to ${filePath}b" +} + diff --git a/.vscode/processT4Templates.ps1 b/.vscode/processT4Templates.ps1 new file mode 100644 index 0000000..b70f07a --- /dev/null +++ b/.vscode/processT4Templates.ps1 @@ -0,0 +1,25 @@ +#!/bin/bash +# buildEffects +# Compiles all .fx files found in the project's Content directory. +# Intended for usage with VS Code Build Tasks tooling. +# You may need to change the path to fxc.exe depending on your installation. + +Write-Output "Starting T4 processing..." + +Set-Location ../project_name + +# create our output directory +if ((Test-Path("T4Templates")) -eq 0) { New-Item -ItemType "directory" -Path "T4Templates" } +if ((Test-Path("T4Templates\Output")) -eq 0) { New-Item -ItemType "directory" -Path "T4Templates\Output"} + +$files = Get-ChildItem ".\T4Templates\*" -Include *.tt + +foreach ($file in $files) +{ + $fileName = $file.BaseName + # Build the template + t4 -r System.dll -r mscorlib.dll -r netstandard.dll -r System.IO.FileSystem.dll -r System.Linq.dll -r System.Text.RegularExpressions -o "T4Templates\Output\${fileName}.cs" "T4Templates\${fileName}.tt" + Write-Output "Built ${fileName}.cs from ${fileName}.tt" +} + + diff --git a/.vscode/tasks.json b/.vscode/tasks.json index bf8d65f..718ba17 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -16,7 +16,7 @@ // - clean, restore and rebuild Nez.FNA.sln (nuget restore Nez.FNA) "label": "Update, Restore and Rebuild Nez", "type": "shell", - "command": "git submodule foreach --recursive git pull && msbuild Nez/Nez.sln '/t:clean;restore;build' && msbuild Nez/Nez.FNA.sln '/t:clean;restore;build'", + "command": "git submodule foreach --recursive git pull && msbuild Nez/Nez.sln /t:clean /t:restore && msbuild Nez/Nez.FNA.sln /t:clean /t:restore", "group": "build", "problemMatcher": "$msCompile", "presentation": { @@ -32,7 +32,7 @@ { "label": "Clean Project", "type": "shell", - "command": "msbuild project_name /t:clean /p:configuration=Debug ; msbuild project_name /t:clean /p:configuration=Release", + "command": "msbuild project_name /t:clean /p:configuration=Debug && msbuild project_name /t:clean /p:configuration=Release", "group": "build", "problemMatcher": "$msCompile", }, @@ -42,8 +42,9 @@ "type": "shell", "command": "msbuild", "args": [ - "project_name", + "project_name.sln", "/p:configuration=Debug", + "/p:platform=Any CPU", "/t:build" ], "group": "build", @@ -51,13 +52,15 @@ "dependsOn": "Build Content", }, + //Confused how release works with this template by default, no release config seems to be setup in the sln { "label": "Build (Release)", "type": "shell", "command": "msbuild", "args": [ - "project_name", + "project_name.sln", "/p:configuration=Release", + "/p:platform=Any CPU", "/t:build" ], "group": "build", @@ -105,7 +108,7 @@ "type": "shell", "group": "build", "osx":{ - "command": "${workspaceFolder}/.vscode/buildEffects.sh" + "command": "${workspaceFolder}/.vscode/buildEffects.ps1" }, "windows":{ "command": "& ${workspaceFolder}/.vscode/buildEffects.ps1" @@ -124,7 +127,8 @@ "problemMatcher": "$msCompile" }, - { + //I dont fully understand this function or how to replicate on windows. + /* { "label": "Force Build Content", "type": "shell", "group": "build", @@ -133,20 +137,20 @@ "cwd": "${workspaceFolder}/project_name/CompiledContent" }, "problemMatcher": "$msCompile" - }, + }, */ { "label": "Open Pipeline Tool", "type": "shell", "group": "build", - "command": "export MONOGAME_PIPELINE_PROJECT=${workspaceFolder}/project_name/CompiledContent/Content.mgcb && /Applications/Pipeline.app/Contents/MacOS/Pipeline", + "command": "${workspaceFolder}/lucid/CompiledContent/Content.mgcb", "problemMatcher": "$msCompile" }, { "label": "Process T4 Templates", "type": "shell", - "command": "${workspaceFolder}/.vscode/processT4Templates.sh", + "command": "${workspaceFolder}/.vscode/processT4Templates.ps1", "group": "build", "problemMatcher": "$msCompile", }, diff --git a/MonoGameContent.targets b/MonoGameContent.targets index fa00c36..9978756 100644 --- a/MonoGameContent.targets +++ b/MonoGameContent.targets @@ -6,7 +6,7 @@ /Library/Frameworks/Mono.framework/External/xbuild + Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Common.props') ">C:\Program Files (x86)\MSBuild $(MSBuildProgramFiles32) bin/DesktopGL @@ -14,7 +14,7 @@ + AssemblyFile="C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Build.Tasks.dll" /> diff --git a/MonoGameContent.targets.bak b/MonoGameContent.targets.bak new file mode 100644 index 0000000..fa00c36 --- /dev/null +++ b/MonoGameContent.targets.bak @@ -0,0 +1,93 @@ + + + + /Library/Frameworks/Mono.framework/External/xbuild + $(MSBuildProgramFiles32) + bin/DesktopGL + obj/DesktopGL + + + + + + + + + + + + true + + + + + $(MonoGameInstallDirectory)\MonoGame\v3.0\ + + /Library/Frameworks/Mono.framework/Versions/Current/bin/mono + /usr/local/bin/mono + /usr/bin/mono + mono + $(MonoGameInstallDir)Tools\MGCB.exe + "$(MonoGameContentBuilderExe)" + $(MonoExe) $(MonoGameContentBuilderCmd) + $(MonoMacResourcePrefix) + $(IPhoneResourcePrefix) + $(MonoAndroidAssetsPrefix) + $(PlatformResourcePrefix)\ + + /quiet +
/platform:$(MonoGamePlatform)
+
+ + + + + + + + + + +
+ + + + + BuildContent; + $(BuildDependsOn); + + + + + + + + + + + + + + + + + +
\ No newline at end of file diff --git a/getFNA.ps1 b/getFNA.ps1 new file mode 100644 index 0000000..46eee3a --- /dev/null +++ b/getFNA.ps1 @@ -0,0 +1,174 @@ +#!/bin/bash +# Program: getFNA +# Author: Caleb Cornett (converted to powershell to work with windows) +# Usage: ./getFNA.sh +# Description: Quick and easy way to install a local copy of FNA and its native libraries. + +# Checks if dotnet is installed +function checkDotnet() +{ + try + { + dotnet | Out-Null + return 1 + } + catch [System.Management.Automation.CommandNotFoundException] + { + Write-Output "ERROR: Dotnet is not installed. Please install dotnet to download the t4 tool." + return 0 + } +} + +function installT4 () +{ + if (checkDotnet) { Invoke-Expression 'dotnet tool install -g dotnet-t4' } +} + +function checkGit () +{ + try { git | Out-Null } + catch [System.Management.Automation.CommandNotFoundException] + { + Write-Output "ERROR: Git is not installed. Please install git to download FNA." + exit + } +} + +function downloadFNA() +{ + checkGit + git -C $PSScriptRoot clone https://github.com/FNA-XNA/FNA.git --recursive + + if ($? -eq 1) { Write-Output "Finished Downloading!" } + else { Write-Output "ERROR: Download failed, try again later?" exit} + +} + +function updateFNA () +{ + checkGit + Write-Output "Updating to the latest git version of FNA..." + + git -C "${PSScriptRoot}\FNA" pull --recurse-submodules + + if ($? -eq 1) { Write-Output "Finished updating!" } + else { Write-Output "ERROR: Unable to update." exit} +} + +function check7zip () +{ + try + { + 7z | Out-Null + } + catch [System.Management.Automation.CommandNotFoundException] + { + Write-Output "ERROR: 7Zip is not installed. Please install 7Zip and set PATH Environment Variable and try again." + exit + } +} + +function getLibs () +{ + Write-Output "Downloading the latest FNAlibs..." + Invoke-WebRequest -Uri http://fna.flibitijibibo.com/archive/fnalibs.tar.bz2 -OutFile "${PSScriptRoot}/fnalibs.tar.bz2" + if ($? -eq 1) { Write-Output "Finished downloading!" } + else { Write-Output "ERROR: Unable to download successfully." exit} + + Write-Output "Decompressing fnalibs..." + check7zip + if ((Test-Path "${PSScriptRoot}\fnalibs") -eq 0) + { + 7z x "fnalibs.tar.bz2" + if ($? -eq 1){ Remove-Item "fnalibs.tar.bz2"} + else { Write-Output "ERROR: Unable to decompress successfully." exit } + 7z x "fnalibs.tar" -ofnalibs + if ($? -eq 1) + { + Remove-Item "fnalibs.tar" + Write-Output "Finished decompressing!" + } + else { Write-Output "ERROR: Unable to decompress successfully." exit } + } + +} + + +if (Test-Path "${PSScriptRoot}\FNA") +{ + #if ((Read-Host -Prompt "Update FNA (y/n)?") -like 'y') { $shouldUpdate = true } + $shouldUpdate = Read-Host -Prompt "Update FNA (y/n)?" +} +else +{ + #if ((Read-Host -Prompt "Download FNA (y/n)?") -like 'y') { $shouldDownload = true } + $shouldDownload = Read-Host -Prompt "Download FNA (y/n)?" +} + +if (Test-Path "${PSScriptRoot}\fnalibs") +{ + #if ((Read-Host -Prompt "Redownload fnalibs (y/n)?") -like 'y') { $shouldDownloadLibs = true } + $shouldDownloadLibs = Read-Host -Prompt "Redownload fnalibs (y/n)?" +} +else +{ + #if ((Read-Host -Prompt "Download fnalibs (y/n)?") -like 'y') { $shouldDownloadLibs = true } + $shouldDownloadLibs = Read-Host -Prompt "Download fnalibs (y/n)?" +} + +if ((Test-Path "${PSScriptRoot}\project_name") -eq 1) +{ + $newProjectName = Read-Host -Prompt "Enter the project name to use for your folder and csproj file or 'exit' to quit: " +} + +if ($shouldDownload -like 'y') { downloadFNA } +elseif ($shouldUpdate -like 'y') { updateFNA } + +if ($shouldDownloadLibs -like 'y') { getLibs } + +installT4 + +# Only proceed from here if we have not yet renamed the project +if ((Test-Path "${PSScriptRoot}\project_name") -ne 1) { exit } + + +if ($newProjectName -eq "exit" -or $newProjectName -eq "") { exit } + +$files= "project_name.sln", + ".gitignore", + "project_name/project_name.csproj", + "project_name/Game1.cs", + "project_name/DemoComponent.cs", + "project_name/DefaultScene.cs", + "project_name/Program.cs", + ".vscode/tasks.json", + ".vscode/settings.json", + ".vscode/launch.json", + ".vscode/buildEffects.sh", + ".vscode/processT4Templates.sh", + ".vscode/buildEffects.ps1", + ".vscode/processT4Templates.ps1" + +foreach ($file in $files) +{ + ((Get-Content -Path $file -Raw) -replace 'project_name', $newProjectName) | Set-Content -Path $file +} + +Rename-Item -Path "project_name.sln" -NewName "${newProjectName}.sln" +Rename-Item -Path "project_name/project_name.csproj" -NewName "${newProjectName}.csproj" +Rename-Item -Path "project_name/project_name.csproj.user" -NewName "${newProjectName}.csproj.user" +Rename-Item -Path "project_name" -NewName $newProjectName + +git init +git submodule add https://github.com/prime31/Nez.git +Set-Location Nez +git submodule init +git submodule update + +"Restoring and rebuilding..." +Set-Location $PSScriptRoot +dotnet restore "Nez/Nez.sln" +msbuild "Nez/Nez.sln" +msbuild -t:restore $newProjectName +msbuild -t:buildcontent $newProjectName +msbuild "${newProjectName}.sln" diff --git a/getFNA.sh b/getFNA.sh deleted file mode 100755 index 9ba3ce4..0000000 --- a/getFNA.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/bin/bash -# Program: getFNA -# Author: Caleb Cornett -# Usage: ./getFNA.sh -# Description: Quick and easy way to install a local copy of FNA and its native libraries. - -# Checks if dotnet is installed -function checkDotnet() -{ - # || { echo >&2 "ERROR: dotnet is not installed. Please install dotnet to download the t4 tool."; exit 1; } - command -v dotnet > /dev/null 2>&1 - if [ ! $? -eq 0 ]; then - echo >&2 "ERROR: dotnet is not installed. Please install dotnet to download the t4 tool." - exit 1 - fi -} - -# Checks if t4 is installed and installs it if it isnt -function installT4() -{ - checkDotnet - command -v t4 > /dev/null 2>&1 - if [ ! $? -eq 0 ]; then - dotnet tool install -g dotnet-t4 - fi -} - -# 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 -} - -# Clones FNA from the git master branch -function downloadFNA() -{ - checkGit - echo "Downloading FNA..." - git -C $MY_DIR clone https://github.com/FNA-XNA/FNA.git --recursive - if [ $? -eq 0 ]; then - echo "Finished downloading!" - else - echo >&2 "ERROR: Unable to download successfully. Maybe try again later?" - fi -} - -# Pulls FNA from the git master branch -function updateFNA() -{ - checkGit - echo "Updating to the latest git version of FNA..." - git -C "$MY_DIR/FNA" pull --recurse-submodules - 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 -} - -# Get the directory of this script -MY_DIR=$(dirname "$BASH_SOURCE") - - -# gather input - -# FNA -if [ ! -d "$MY_DIR/FNA" ]; then - read -p "Download FNA (y/n)? " shouldDownload -else - read -p "Update FNA (y/n)? " shouldUpdate -fi - -if [ ! -d "$MY_DIR/fnalibs" ]; then - read -p "Download fnalibs (y/n)? " shouldDownloadLibs -else - read -p "Redownload fnalibs (y/n)? " shouldDownloadLibs -fi - - -# act on the input - -# FNA -if [[ $shouldDownload =~ ^[Yy]$ ]]; then - downloadFNA -elif [[ $shouldUpdate =~ ^[Yy]$ ]]; then - updateFNA -fi - -# FNALIBS -if [[ $shouldDownloadLibs =~ ^[Yy]$ ]]; then - getLibs -fi - - -# install t4 engine -installT4 - - - -# Only proceed from here if we have not yet renamed the project -if [ ! -d "$MY_DIR/project_name" ]; then - # old project_name folder already renamed so we are all done here - exit 1 -fi - - -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 - -# any files that need to have project_name replaced with the new project name should be here -files=(project_name.sln .gitignore project_name/project_name.csproj project_name/Game1.cs project_name/DemoComponent.cs project_name/DefaultScene.cs project_name/Program.cs .vscode/tasks.json .vscode/settings.json .vscode/launch.json .vscode/buildEffects.sh .vscode/processT4Templates.sh) -for file in "${files[@]}"; do - sed -i '' "s/project_name/$newProjectName/g" $file -done - -mv project_name.sln "$newProjectName.sln" -mv project_name/project_name.sln "project_name/$newProjectName.sln" -mv project_name/project_name.csproj "project_name/$newProjectName.csproj" -mv project_name/project_name.csproj.user "project_name/$newProjectName.csproj.user" -mv project_name "$newProjectName" - -git init -git submodule add https://github.com/prime31/Nez.git -cd Nez -git submodule init -git submodule update - -command -v pbcopy > /dev/null 2>&1 -if [ ! $? -eq 0 ]; then - printf "\n\nManually run the following command:\n\nnuget restore Nez/Nez.sln && msbuild Nez/Nez.sln && msbuild /t:restore $newProjectName && msbuild $newProjectName.sln\n\n" -else - echo "nuget restore Nez/Nez.sln && msbuild Nez/Nez.sln && msbuild /t:restore $newProjectName && msbuild $newProjectName.sln" | pbcopy - echo "" - echo "A build command was copied to your clipboard. Paste and run it now." - echo "" -fi