Search code examples
javascriptvisual-studio-2010msbuildyuiyui-compressor

Creating new Directory with YUI Compressor task MSBuild Event


I am using YUI for minification. It all works fine. I am planning to keep the generated file in a different directory each time. But if i give a path which doesn't not exist , this task is not able to generate the directory. for me the number 79 will keep changing so that everytime its a new path. If the folder already exists then it fines it copies the minified file.

Any idea or help in creating directory if not exists while generating the file.

I integrated the below one with MSBuild as post build event

 <JavaScriptCompressorTask
         SourceFiles="@(jsfile_global)"
         DeleteSourceFiles="false"
         OutputFile="minified/79/global-min.js"
         CompressionType="Standard"
         LoggingType="Info"
         LineBreakPosition="-1"         
    />

any help or direction will be really appreciated.

Thanks.


Solution

  • The following will create the directory, if not existing:

    <PropertyGroup>
      <Number>79</Number>
    </PropertyGroup>
    
    <MakeDir Directories="minified/$(Number)/" Condition="!Exists('minified/$(Number)/')" />
    <JavaScriptCompressorTask
         SourceFiles="@(jsfile_global)"
         DeleteSourceFiles="false"
         OutputFile="minified/$(Number)/global-min.js"
         CompressionType="Standard"
         LoggingType="Info"
         LineBreakPosition="-1"         
    />