Created
June 1, 2012 14:32
-
-
Save tugberkugurlu/2852551 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################## | |
#resources | |
################################################## | |
#http://blogs.msdn.com/b/kalleb/archive/2008/07/19/using-powershell-to-read-xml-files.aspx | |
#http://tfl09.blogspot.com/2007/11/formatting-with-powershell.html | |
#http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-conditional-logic/ | |
################################################## | |
#resources | |
################################################## | |
$solutionDir = ".\" | |
$projectDir = "{0}BundleMinifyStuffTry\" -f $solutionDir | |
$bundleXml = "{0}App_Data\Bundle.xml" -f $projectDir | |
$bundleXmlFullPath = (resolve-path $bundleXml).Path | |
sal ___AjaxMin .\tools\AjaxMin.exe | |
$bundleXmlFile = [xml](get-content($bundleXmlFullPath)) | |
$bundleTypes = $bundleXmlFile.metadata.types.item | |
$bundleBundles = $bundleXmlFile.metadata.bundles.bundle | |
foreach($type in $bundleTypes) { | |
$_type = $type.type | |
$_fileExtension = $type.fileExtension | |
$_rootDir = $type.rootDir | |
$_rootDestination = $type.rootDestination | |
$_copyFiles = $type.copyFiles | |
$_destinationDir = "{0}{1}" -f $projectDir, $_rootDestination | |
#test if the dir exists and create if not | |
if(!(Test-Path $_destinationDir)) { | |
#destination dir does not exist, creating it | |
mkdir $_destinationDir | |
} | |
$_bundle = $bundleBundles | where { $_.type -eq $_type } | |
foreach($__bundle in $_bundle) { | |
$__output = $__bundle.output | |
$__outputFileDir = "{0}{1}.min.{2}" -f $_destinationDir, $__output, $_fileExtension | |
$__fileNamesState | |
foreach($__file in $__bundle.file) { | |
$__fileName = '"{0}{1}{2}.{3}"' -f $projectDir, $_rootDir, $__file.dir, $_fileExtension | |
$__fileNamesState += "{0} " -f $__fileName | |
} | |
$__filesToBundle = $__fileNamesState | |
#bundle and minify | |
___AjaxMin -clobber $__filesToBundle -o $__outputFileDir | |
$__fileNamesState = $null | |
} | |
if($_copyFiles) { | |
Copy-Item ("{0}{1}*" -f $projectDir, $_rootDir) $_destinationDir -force -recurse | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<metadata> | |
<types> | |
<item type="js" fileExtension="js" rootDir="scripts/" rootDestination="assets/js/" /> | |
<item type="css" fileExtension="css" rootDir="content/" rootDestination="assets/css/" copyFiles="true" /> | |
</types> | |
<bundles> | |
<!--CSS Bundles--> | |
<bundle type="css" output="global"> | |
<file dir="bootstrap" /> | |
<file dir="style" /> | |
</bundle> | |
<!--JS Bundles--> | |
<bundle type="js" output="global"> | |
<file dir="jquery-1.7.2" /> | |
<file dir="jquery-ui-1.8.20" /> | |
<file dir="knockout-2.1.0.debug" /> | |
<file dir="jquery.validate" /> | |
<file dir="jquery.validate.unobtrusive" /> | |
<file dir="bootstrap" /> | |
</bundle> | |
<bundle type="js" output="app/index"> | |
<file dir="app/index" /> | |
</bundle> | |
</bundles> | |
</metadata> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment