Advertisement
Guest User

VS2012 XNA Package Utility

a guest
Sep 23rd, 2013
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 3.01 KB | None | 0 0
  1. ::======================= XNA Package Utility ========================::
  2. :: Author:          Robert Jordan
  3. :: Last Updated:    9/23/2013
  4. ::
  5. :: For use with the Visual Studio 2012 External Tools
  6. :: Setup:
  7. ::      Goto Tools>External Tools... and press the Add button.
  8. ::      Title: <irrelevant>
  9. ::      Command: <path-to-batch>\XnaPack.bat
  10. ::      Arguments: $(BinDir)$(TargetName)$(TargetExt) [other arguments]
  11. ::      Initial directory: $(BinDir)
  12. ::      [X] Use Output window
  13. ::      [ ] Prompt for arguments
  14. ::      [ ] Treat output as Unicode
  15. ::      [~] Close on exit (Grayed out)
  16. :: How to use the thumbnail argument:
  17. ::      /thumbnail:$(ProjectDir)$(ProjectFileName)
  18. ::      There is no argument for the thumbnail name so this batch file
  19. ::      will find the Thumbnail xml property in the project file.
  20. :: Notes:
  21. ::      - This will affect whichever project is currently selected.
  22. ::      - Your project must be previously compiled.
  23. ::      - The thumbnail argument can be "/thumbnail:" or "/th:".
  24. :: Recommended Arguments:
  25. ::      $(BinDir)$(TargetName)$(TargetExt) /nologo /thumbnail:$(ProjectDir)$(ProjectFileName)
  26. :: MSDN Reference:
  27. ::      http://msdn.microsoft.com/en-us/library/ff434644.aspx
  28. ::====================================================================::
  29. @echo off
  30. title XNA Package Utility
  31.  
  32. :: Store the current directory for later
  33. set CurrentDir=%cd%
  34. :: The list of commands for xnapack
  35. set Commands=
  36. :: The default thumbnail file
  37. set ThumbnailFile=GameThumbnail.png
  38.  
  39. :: Collect the commands and get the thumbnail file property from the project file
  40. setlocal EnableDelayedExpansion
  41. for %%x in (%*) do (
  42.     set tmp1=%%x
  43.     set tmp1=!tmp1:"=!
  44.     :: Check if this is the thumbnail argument so it can be corrected
  45.     if "!tmp1:~0,11!"=="/thumbnail:" (
  46.         set ProjectPath=!tmp1:~11!
  47.         :: Find the <Thumbnail> xml property in the project file
  48.         for /f "tokens=3 delims=^<^>" %%a in ('findstr /r /c:"\<Thumbnail\>.*\</Thumbnail\>" "!ProjectPath!"') do set ThumbnailFile=%%a
  49.         :: Get the directory of the project file (and the thumbnail file as well)
  50.         cd "!ProjectPath!\.."
  51.         set ProjectPath=!cd!
  52.         :: Add the corrected command to the list
  53.         set Commands=!Commands! /thumbnail:"!ProjectPath!\!ThumbnailFile!"
  54.     ) else (
  55.     if "!tmp1:~0,4!"=="/th:" (
  56.         set ProjectPath=!tmp1:~4!
  57.         for /f "tokens=3 delims=^<^>" %%b in ('findstr /r /c:"\<Thumbnail\>.*\</Thumbnail\>" "!ProjectPath!"') do set ThumbnailFile=%%b
  58.         cd "!ProjectPath!\.."
  59.         set ProjectPath=!cd!
  60.         set Commands=!Commands! /th:"!ProjectPath!\!ThumbnailFile!"
  61.     ) else (
  62.         :: Add the command to the list
  63.         set Commands=!Commands! %%x
  64.     ))
  65. )
  66. endlocal & set Commands=%Commands%
  67.  
  68. :: Start up the XNA command prompt environment
  69. 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"
  70. :: Change the current directory back the original one since the the above call will change it
  71. cd %CurrentDir%
  72.  
  73. :: Begin the packaging process
  74. xnapack %Commands%
  75.  
  76. @exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement