mirror of
https://github.com/prime31/FNA-VSCode-Template.git
synced 2025-10-31 21:50:44 +07:00
Ported bash files to powershell, now functions in Windows
Still need to fix up a few lingering things. Need to figure out how the original sln file was functioning with Release configuration without having a Release config set up. Would also be nice to have some way to install and run the powershell script from code, so it would be as simple as creating the folder for the new project > right click > open with Code > (run command from pallette for new Nez project from template)
This commit is contained in:
parent
3e0088aabf
commit
7975cccbe9
23
.vscode/buildEffects.ps1
vendored
Normal file
23
.vscode/buildEffects.ps1
vendored
Normal file
@ -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"
|
||||
}
|
||||
|
||||
25
.vscode/processT4Templates.ps1
vendored
Normal file
25
.vscode/processT4Templates.ps1
vendored
Normal file
@ -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"
|
||||
}
|
||||
|
||||
|
||||
22
.vscode/tasks.json
vendored
22
.vscode/tasks.json
vendored
@ -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",
|
||||
},
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MonoGameInstallDirectory
|
||||
Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('/Library/Frameworks/Mono.framework/External/xbuild/MonoGame/v3.0/MonoGame.Common.props') ">/Library/Frameworks/Mono.framework/External/xbuild</MonoGameInstallDirectory>
|
||||
Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Common.props') ">C:\Program Files (x86)\MSBuild</MonoGameInstallDirectory>
|
||||
<MonoGameInstallDirectory
|
||||
Condition=" '$(MonoGameInstallDirectory)' == '' ">$(MSBuildProgramFiles32)</MonoGameInstallDirectory>
|
||||
<ContentOutputDir>bin/DesktopGL</ContentOutputDir>
|
||||
@ -14,7 +14,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask TaskName="MonoGame.Build.Tasks.CollectContentReferences"
|
||||
AssemblyFile="\Library\Frameworks\MonoGame.framework\v3.0\MonoGame.Build.Tasks.dll" />
|
||||
AssemblyFile="C:\Program Files (x86)\MSBuild\MonoGame\v3.0\MonoGame.Build.Tasks.dll" />
|
||||
|
||||
<!-- Add MonoGameContentReference to item type selection in Visual Studio -->
|
||||
<ItemGroup>
|
||||
|
||||
93
MonoGameContent.targets.bak
Normal file
93
MonoGameContent.targets.bak
Normal file
@ -0,0 +1,93 @@
|
||||
<!--
|
||||
The main project needs a reference to this project. We use our own instead of the default MonoGame version so we can control
|
||||
where our content gets built since we don't use "Content" but instead use "CompiledContent"
|
||||
<Import Project="../MonoGameContent.targets" />
|
||||
-->
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<MonoGameInstallDirectory
|
||||
Condition=" '$(MonoGameInstallDirectory)' == '' And Exists('/Library/Frameworks/Mono.framework/External/xbuild/MonoGame/v3.0/MonoGame.Common.props') ">/Library/Frameworks/Mono.framework/External/xbuild</MonoGameInstallDirectory>
|
||||
<MonoGameInstallDirectory
|
||||
Condition=" '$(MonoGameInstallDirectory)' == '' ">$(MSBuildProgramFiles32)</MonoGameInstallDirectory>
|
||||
<ContentOutputDir>bin/DesktopGL</ContentOutputDir>
|
||||
<ContentIntermediateDir>obj/DesktopGL</ContentIntermediateDir>
|
||||
</PropertyGroup>
|
||||
|
||||
<UsingTask TaskName="MonoGame.Build.Tasks.CollectContentReferences"
|
||||
AssemblyFile="\Library\Frameworks\MonoGame.framework\v3.0\MonoGame.Build.Tasks.dll" />
|
||||
|
||||
<!-- Add MonoGameContentReference to item type selection in Visual Studio -->
|
||||
<ItemGroup>
|
||||
<AvailableItemName Include="MonoGameContentReference" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- This disables the IDE feature that skips executing msbuild in some build situations. -->
|
||||
<PropertyGroup>
|
||||
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="Prepare">
|
||||
<PropertyGroup>
|
||||
<MonoGameInstallDir>$(MonoGameInstallDirectory)\MonoGame\v3.0\</MonoGameInstallDir>
|
||||
<!-- El Capitan Support -->
|
||||
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/Library/Frameworks/Mono.framework/Versions/Current/bin/mono') ">/Library/Frameworks/Mono.framework/Versions/Current/bin/mono</MonoExe>
|
||||
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/local/bin/mono') ">/usr/local/bin/mono</MonoExe>
|
||||
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And Exists ('/usr/bin/mono') ">/usr/bin/mono</MonoExe>
|
||||
<MonoExe Condition=" '$(OS)' != 'Windows_NT' And '$(MonoExe)' == '' ">mono</MonoExe>
|
||||
<MonoGameContentBuilderExe Condition="'$(MonoGameContentBuilderExe)' == ''">$(MonoGameInstallDir)Tools\MGCB.exe</MonoGameContentBuilderExe>
|
||||
<MonoGameContentBuilderCmd>"$(MonoGameContentBuilderExe)"</MonoGameContentBuilderCmd>
|
||||
<MonoGameContentBuilderCmd Condition=" '$(OS)' != 'Windows_NT' ">$(MonoExe) $(MonoGameContentBuilderCmd)</MonoGameContentBuilderCmd>
|
||||
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'MacOSX'">$(MonoMacResourcePrefix)</PlatformResourcePrefix>
|
||||
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'iOS'">$(IPhoneResourcePrefix)</PlatformResourcePrefix>
|
||||
<PlatformResourcePrefix Condition="'$(MonoGamePlatform)' == 'Android'">$(MonoAndroidAssetsPrefix)</PlatformResourcePrefix>
|
||||
<PlatformResourcePrefix Condition="'$(PlatformResourcePrefix)' != '' And !HasTrailingSlash('$(PlatformResourcePrefix)')">$(PlatformResourcePrefix)\</PlatformResourcePrefix>
|
||||
<PlatformResourcePrefix Condition="'$(PlatformResourcePrefix)' == ''"></PlatformResourcePrefix>
|
||||
<MonoGameMGCBAdditionalArguments Condition="'$(MonoGameMGCBAdditionalArguments)' ==''">/quiet</MonoGameMGCBAdditionalArguments>
|
||||
<Header>/platform:$(MonoGamePlatform)</Header>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Get all Mono Game Content References and store them in a list -->
|
||||
<!-- We do this here so we are compatible with xbuild -->
|
||||
<CollectContentReferences ContentReferences="@(MonoGameContentReference)" MonoGamePlatform="$(MonoGamePlatform)">
|
||||
<Output TaskParameter="Output" ItemName="ContentReferences" />
|
||||
</CollectContentReferences>
|
||||
|
||||
<Error
|
||||
Text="The MonoGame content builder executable could not be located at '$(MonoGameContentBuilderExe)'!"
|
||||
Condition="!Exists('$(MonoGameContentBuilderExe)')"
|
||||
/>
|
||||
|
||||
<Warning
|
||||
Text="No Content References Found. Please make sure your .mgcb file has a build action of MonoGameContentReference"
|
||||
Condition=" '%(ContentReferences.FullPath)' == '' "
|
||||
/>
|
||||
</Target>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<BuildDependsOn>
|
||||
BuildContent;
|
||||
$(BuildDependsOn);
|
||||
</BuildDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="RunContentBuilder">
|
||||
<Exec Condition=" '%(ContentReferences.FullPath)' != '' "
|
||||
Command="$(MonoGameContentBuilderCmd) $(MonoGameMGCBAdditionalArguments) $(Header) /@:"%(ContentReferences.FullPath)" /outputDir:"$(ContentOutputDir)" /intermediateDir:"$(ContentIntermediateDir)""
|
||||
WorkingDirectory="%(ContentReferences.RootDir)%(ContentReferences.Directory)" />
|
||||
<CreateItem Include="%(ContentReferences.RelativeFullPath)%(ContentReferences.ContentOutputDir)\**\*.*"
|
||||
AdditionalMetadata="ContentOutputDir=%(ContentReferences.ContentDirectory)">
|
||||
<Output TaskParameter="Include" ItemName="ExtraContent" />
|
||||
</CreateItem>
|
||||
</Target>
|
||||
|
||||
<Target Name="BuildContent" DependsOnTargets="Prepare;RunContentBuilder" AfterTargets="Build" Condition=" '@(MonoGameContentReference)' != '' "
|
||||
Outputs="%(ExtraContent.RecursiveDir)%(ExtraContent.Filename)%(ExtraContent.Extension)">
|
||||
<CreateItem Include="%(ExtraContent.FullPath)" AdditionalMetadata="Link=$(PlatformResourcePrefix)%(ExtraContent.ContentOutputDir)%(ExtraContent.RecursiveDir)%(ExtraContent.Filename)%(ExtraContent.Extension);CopyToOutputDirectory=PreserveNewest"
|
||||
Condition="'%(ExtraContent.Filename)' != ''">
|
||||
<Output TaskParameter="Include" ItemName="Content" Condition="'$(MonoGamePlatform)' != 'Android' And '$(MonoGamePlatform)' != 'iOS' And '$(MonoGamePlatform)' != 'MacOSX'" />
|
||||
<Output TaskParameter="Include" ItemName="BundleResource" Condition="'$(MonoGamePlatform)' == 'MacOSX' Or '$(MonoGamePlatform)' == 'iOS'" />
|
||||
<Output TaskParameter="Include" ItemName="AndroidAsset" Condition="'$(MonoGamePlatform)' == 'Android'" />
|
||||
</CreateItem>
|
||||
</Target>
|
||||
</Project>
|
||||
174
getFNA.ps1
Normal file
174
getFNA.ps1
Normal file
@ -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"
|
||||
171
getFNA.sh
171
getFNA.sh
@ -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
|
||||
Loading…
Reference in New Issue
Block a user