windows support from PR 3

This commit is contained in:
Mike 2019-09-20 23:03:36 -07:00
parent 98ccbd2f66
commit e97423d34f
7 changed files with 287 additions and 18 deletions

26
.vscode/launch.json vendored
View File

@ -4,8 +4,9 @@
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"name": "Launch (Mac)",
"type": "mono",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
@ -14,12 +15,12 @@
"osx":{
"env": {
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
},
}
}
},
{
"name": "Launch Without Building",
"name": "Launch Without Building (Mac)",
"type": "mono",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
@ -27,10 +28,27 @@
"osx":{
"env": {
"DYLD_LIBRARY_PATH": "${workspaceFolder}/project_name/bin/Debug/osx/"
},
}
}
},
{
"name": "Launch (Windows)",
"type": "clr",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"cwd": "${workspaceFolder}/project_name",
"preLaunchTask": "Build (Debug)"
},
{
"name": "Launch Without Building (Windows)",
"type": "clr",
"request": "launch",
"program": "${workspaceFolder}/project_name/bin/Debug/project_name.exe",
"cwd": "${workspaceFolder}"
},
{
"name": "Attach",
"type": "mono",

27
.vscode/processT4Templates.ps1 vendored Normal file
View File

@ -0,0 +1,27 @@
#!/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 $PSScriptRoot
Set-Location ..\project_name
# create our output directory
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"
}

53
.vscode/tasks.json vendored
View File

@ -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",
@ -56,8 +57,9 @@
"type": "shell",
"command": "msbuild",
"args": [
"project_name",
"project_name.sln",
"/p:configuration=Release",
"/p:platform=Any CPU",
"/t:build"
],
"group": "build",
@ -72,9 +74,9 @@
"command": "DYLD_LIBRARY_PATH=${workspaceFolder}/project_name/bin/Debug/osx/ mono ${workspaceFolder}/project_name/bin/Debug/project_name.exe"
},
"windows":{
"command": "cmd",
"command": "start",
"args": [
"/k",
"/wait",
"${workspaceFolder}/project_name/bin/Debug/project_name.exe"
]
},
@ -90,9 +92,9 @@
"command": "DYLD_LIBRARY_PATH=${workspaceFolder}/project_name/bin/Release/osx/ mono ${workspaceFolder}/project_name/bin/Release/project_name.exe"
},
"windows":{
"command": "cmd",
"command": "start",
"args": [
"/k",
"/wait",
"${workspaceFolder}/project_name/bin/Release/project_name.exe"
]
},
@ -108,7 +110,11 @@
"command": "${workspaceFolder}/.vscode/buildEffects.sh"
},
"windows":{
"command": "& ${workspaceFolder}/.vscode/buildEffects.ps1"
"command": "powershell",
"args": [
"-File",
"${workspaceFolder}/.vscode/buildEffects.ps1"
],
},
"problemMatcher": "$msCompile"
},
@ -128,7 +134,16 @@
"label": "Force Build Content",
"type": "shell",
"group": "build",
"command": "mono /Applications/Pipeline.app/Contents/MonoBundle/MGCB.exe /@:Content.mgcb -r",
"osx": {
"command": "mono /Applications/Pipeline.app/Contents/MonoBundle/MGCB.exe /@:Content.mgcb -r",
},
"windows": {
"command":"C:/Program Files (x86)/MSBuild/MonoGame/v3.0/Tools/MGCB.exe",
"args": [
"/@:Content.mgcb",
"-r"
]
},
"options": {
"cwd": "${workspaceFolder}/project_name/CompiledContent"
},
@ -139,14 +154,28 @@
"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",
"osx": {
"command": "export MONOGAME_PIPELINE_PROJECT=${workspaceFolder}/project_name/CompiledContent/Content.mgcb && /Applications/Pipeline.app/Contents/MacOS/Pipeline"
},
"windows": {
"command": "${workspaceFolder}/project_name/CompiledContent/Content.mgcb"
},
"problemMatcher": "$msCompile"
},
{
"label": "Process T4 Templates",
"type": "shell",
"command": "${workspaceFolder}/.vscode/processT4Templates.sh",
"osx": {
"command": "${workspaceFolder}/.vscode/processT4Templates.sh"
},
"windows": {
"command": "powershell",
"args": [
"-File",
"${workspaceFolder}/.vscode/processT4Templates.ps1"
]
},
"group": "build",
"problemMatcher": "$msCompile",
},

View File

@ -11,15 +11,17 @@ Start new FNA projects with Nez quickly and easily with handy setup scripts, a v
## Prerequisites ##
- [Visual Studio Code](https://code.visualstudio.com) or [Visual Studio](https://visualstudio.microsoft.com/) (recommended to use Visual Studio Code because it has some custom tasks but either will work fine)
- [Mono Debugger Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) (required for macOS debugging)
- [Mono Debugger Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.mono-debug) (required for macOS debugging)
- [MonoGame](http://www.monogame.net/downloads/) (required for compiling content with the Pipeline tool)
- (optional) [.NET Core](https://dotnet.microsoft.com/download) (required for compiling T4 templates)
- (optional) [Microsoft DirectX SDK (June 2010)](https://www.microsoft.com/en-us/download/details.aspx?id=6812) (required for building effects, [you can use Wine to run this](https://github.com/AndrewRussellNet/FNA-Template#linuxmacos-installing-the-directx-sdk-on-wine))
- (windows only) [7zip](https://www.7-zip.org) (if intending to use fnalibs, the filetype is unsupported for windows and requires 7zip to be installed to decompress/unzip)
- (windows only) [Build tools for Visua Studio](https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=BuildTools&rel=16)(these build tools are required for all Visual Studio Code build tasks. if you intend to use the full Visual Studio, these are already included. be sure to include .NET Core Build Tools in the installation)
## Setup Instructions ##
1. Download and unzip the ZIP archive (don't clone the repo!)
2. Run `./getFNA.sh` (macOS) to download the latest Nez, FNA and fnalibs to the directory. You can run this script again if you want to update either FNA or the fnalibs at a later point.
2. Run `./getFNA.sh` (macOS) or `./getFNA.ps1` (windows) to download the latest Nez, FNA and fnalibs to the directory. You can run this script again if you want to update either FNA or the fnalibs at a later point.
3. Open the root folder that contains the .sln file in Visual Studio Code or the .sln file directly in Visual Studio. Note that only Visual Studio Code has an effect builder command.
That's it! Now you're ready to build and run the base project. If you get missing DLL errors (pointing at SDL) when running in Visual Studio copy the FNA libs into your `/usr/local/lib` folder. With Visual Studio Code, `DYLD_LIBRARY_PATH` is set automatically so it won't run into the DLL not found error. Nez is setup as a submodule so you can update it in the normal fashion.

181
getFNA.ps1 Normal file
View File

@ -0,0 +1,181 @@
#!/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 }
catch [System.Management.Automation.CommandNotFoundException]
{
Write-Output "ERROR: Dotnet is not installed. Please install dotnet to download the t4 tool."
exit
}
}
function checkMsbuild ()
{
try { msbuild | Out-Null }
catch [System.Management.Automation.CommandNotFoundException]
{
Write-Output "ERROR: Msbuild is not available, please ensure msbuild.exe is installed and added to the PATH Environment Variable."
exit
}
}
function check7zip ()
{
if ((Test-Path "C:\Program Files\7-Zip") -eq 0)
{
Write-Output "ERROR: 7zip is not installed, please install 7zip and try again."
exit
}
}
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 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)
{
& "C:\Program Files\7-Zip\7z.exe" x "fnalibs.tar.bz2"
if ($? -eq 1){ Remove-Item "fnalibs.tar.bz2"}
else { Write-Output "ERROR: Unable to decompress successfully." exit }
& "C:\Program Files\7-Zip\7z.exe" x "fnalibs.tar" -ofnalibs
if ($? -eq 1)
{
Remove-Item "fnalibs.tar"
Write-Output "Finished decompressing!"
}
else { Write-Output "ERROR: Unable to decompress successfully." exit }
}
}
checkMsbuild
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..."
Set-Location $PSScriptRoot
dotnet restore "Nez/Nez.sln"
"Building..."
msbuild "Nez/Nez.sln"
msbuild -t:restore $newProjectName
msbuild -t:buildcontent $newProjectName
msbuild "${newProjectName}.sln"

View File

@ -24,8 +24,19 @@ Global
{16DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CB9E917-FEF7-453F-A88D-6B85B552B058}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CB9E917-FEF7-453F-A88D-6B85B552B058}.Release|Any CPU.Build.0 = Release|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35253CE1-C864-4CD3-8249-4D1319748E8F}.Release|Any CPU.Build.0 = Release|Any CPU
{11A5855C-B12C-4F8D-B935-56F3D0B671C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{11A5855C-B12C-4F8D-B935-56F3D0B671C3}.Release|Any CPU.Build.0 = Release|Any CPU
{16DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{16DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.Build.0 = Release|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{26DA6D66-4DFD-46D4-A367-C02B48B80CAA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
EndGlobal

View File

@ -8,6 +8,7 @@
<AssemblyName>project_name</AssemblyName>
<MonoGamePlatform>DesktopGL</MonoGamePlatform>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<!-- Reference FNA, Nez, ImGui and Persistence projects. Optionally add a Farseer reference here and in the .sln file -->