Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::======================= XNA Package Utility ========================::
- :: Author: Robert Jordan
- :: Last Updated: 9/23/2013
- ::
- :: For use with the Visual Studio 2012 External Tools
- :: Setup:
- :: Goto Tools>External Tools... and press the Add button.
- :: Title: <irrelevant>
- :: Command: <path-to-batch>\XnaPack.bat
- :: Arguments: $(BinDir)$(TargetName)$(TargetExt) [other arguments]
- :: Initial directory: $(BinDir)
- :: [X] Use Output window
- :: [ ] Prompt for arguments
- :: [ ] Treat output as Unicode
- :: [~] Close on exit (Grayed out)
- :: How to use the thumbnail argument:
- :: /thumbnail:$(ProjectDir)$(ProjectFileName)
- :: There is no argument for the thumbnail name so this batch file
- :: will find the Thumbnail xml property in the project file.
- :: Notes:
- :: - This will affect whichever project is currently selected.
- :: - Your project must be previously compiled.
- :: - The thumbnail argument can be "/thumbnail:" or "/th:".
- :: Recommended Arguments:
- :: $(BinDir)$(TargetName)$(TargetExt) /nologo /thumbnail:$(ProjectDir)$(ProjectFileName)
- :: MSDN Reference:
- :: http://msdn.microsoft.com/en-us/library/ff434644.aspx
- ::====================================================================::
- @echo off
- title XNA Package Utility
- :: Store the current directory for later
- set CurrentDir=%cd%
- :: The list of commands for xnapack
- set Commands=
- :: The default thumbnail file
- set ThumbnailFile=GameThumbnail.png
- :: Collect the commands and get the thumbnail file property from the project file
- setlocal EnableDelayedExpansion
- for %%x in (%*) do (
- set tmp1=%%x
- set tmp1=!tmp1:"=!
- :: Check if this is the thumbnail argument so it can be corrected
- if "!tmp1:~0,11!"=="/thumbnail:" (
- set ProjectPath=!tmp1:~11!
- :: Find the <Thumbnail> xml property in the project file
- for /f "tokens=3 delims=^<^>" %%a in ('findstr /r /c:"\<Thumbnail\>.*\</Thumbnail\>" "!ProjectPath!"') do set ThumbnailFile=%%a
- :: Get the directory of the project file (and the thumbnail file as well)
- cd "!ProjectPath!\.."
- set ProjectPath=!cd!
- :: Add the corrected command to the list
- set Commands=!Commands! /thumbnail:"!ProjectPath!\!ThumbnailFile!"
- ) else (
- if "!tmp1:~0,4!"=="/th:" (
- set ProjectPath=!tmp1:~4!
- for /f "tokens=3 delims=^<^>" %%b in ('findstr /r /c:"\<Thumbnail\>.*\</Thumbnail\>" "!ProjectPath!"') do set ThumbnailFile=%%b
- cd "!ProjectPath!\.."
- set ProjectPath=!cd!
- set Commands=!Commands! /th:"!ProjectPath!\!ThumbnailFile!"
- ) else (
- :: Add the command to the list
- set Commands=!Commands! %%x
- ))
- )
- endlocal & set Commands=%Commands%
- :: Start up the XNA command prompt environment
- call "C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\Tools\XnaGseVars.cmd" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\";"C:\Windows\Microsoft.NET\Framework\v3.5\";"C:\Windows\Microsoft.NET\Framework\v2.0.50727"
- :: Change the current directory back the original one since the the above call will change it
- cd %CurrentDir%
- :: Begin the packaging process
- xnapack %Commands%
- @exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement