0 length javascript files

Feb 26, 2009 at 9:13 AM
I'm trying nameetpai solution to get a folder of javascript and css files and convert them as a batch.

All javascripts are stored in 'js' folder.
All css are stored in 'theme' folder.
I have copied the dll's to web deployment root folder.
The project is pure js/css/html and I'm using Build command from VS2008.

The problem is that css files are compressed succesfully but javascript files don't. They're just created with 0 bytes size. Any idea? It seems they have been discovered but not compressed.

This is my .wdproj:


<!--
  Microsoft Visual Studio 2008 Web Deployment Project   http://go.microsoft.com/fwlink/?LinkID=104956

-->
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <!-- Please take careful note of the PATH to the custom build task. -->
  <UsingTask TaskName="CompressorTask" AssemblyFile="Yahoo.Yui.Compressor.dll" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>9.0.21022</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{AD2A834D-E9F3-45D8-83D6-7D549CE9A547}</ProjectGuid>
    <SourceWebPhysicalPath>..\GCBrowser</SourceWebPhysicalPath>
    <SourceWebProject>{6A478052-A0DC-426D-BF7A-A169410B05C3}|C:\Proyectos\GCBrowser</SourceWebProject>
    <SourceWebVirtualPath>/GCBrowser</SourceWebVirtualPath>
    <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <OutputPath>.\Debug</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
    <SingleAssemblyName>GCBrowser_deploy</SingleAssemblyName>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>false</DebugSymbols>
    <OutputPath>.\Release</OutputPath>
    <EnableUpdateable>true</EnableUpdateable>
    <UseMerge>true</UseMerge>
    <SingleAssemblyName>GCBrowser_deploy</SingleAssemblyName>
  </PropertyGroup>
  <ItemGroup>
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\WebDeployment\v9.0\Microsoft.WebDeployment.targets" />
  <Target Name="AfterMerge">
    <!-- Create the list of files: you can create an explicit semi-colon delimited list or use wildcards as below -->
    <CreateItem Include="$(TempBuildDir)js\*.js">
      <Output TaskParameter="Include" ItemName="JavaScriptFiles" />
    </CreateItem>
    <CreateItem Include="$(TempBuildDir)theme\*.css">
      <Output TaskParameter="Include" ItemName="CssFiles" />
    </CreateItem>
    
    <!-- Execute CompressorTask for each file in the list -->
    <CompressorTask
       Condition="'%(JavaScriptFiles.Identity)' != ''"
       JavaScriptFiles="%(JavaScriptFiles.Identity)"
       ObfuscateJavaScript="FoSho"
       PreserveAllSemicolons="Yeah"
       DisableOptimizations="Nope"
       EncodingType="Default"
       DeleteJavaScriptFiles="false"
       JavaScriptOutputFile="%(JavaScriptFiles.Identity)"
       LoggingType="ALittleBit" />
    <CompressorTask
       Condition="'%(CssFiles.Identity)' != ''"
       CssFiles="%(CssFiles.Identity)"
       DeleteCssFiles="false"
       CssOutputFile="%(CssFiles.Identity)"
       CssCompressionType="YuiStockCompression"
       EncodingType="Default"
       LoggingType="ALittleBit" />
  </Target>
</Project>

Coordinator
Feb 26, 2009 at 10:08 PM
Hello Beltire,

have you tried just compressing ONE js file to see if that works?

eg.
JavaScriptFiles="SomeFile1.js"
JavaScriptOutputFile="SomeFile.js"  or JavaScriptOutputFile="SomeFile1.min.js"


... this will then check to see that the latest code you have DOES work, etc. then we can rule out that it's the msbuild task code and look at fixing the msbuild wildcard stuff.
Feb 27, 2009 at 7:09 AM
I've tested the following with 1 only file:


 <Target Name="AfterMerge">
    <!-- Create the list of files: you can create an explicit semi-colon delimited list or use wildcards as below -->
    <CreateItem Include="$(TempBuildDir)js\*.js">
      <Output TaskParameter="Include" ItemName="JavaScriptFiles" />
    </CreateItem>
    <CreateItem Include="$(TempBuildDir)theme\*.css">
      <Output TaskParameter="Include" ItemName="CssFiles" />
    </CreateItem>
    <!-- Execute CompressorTask for each file in the list -->
    <CompressorTask
      Condition="'%(JavaScriptFiles.Identity)' != ''"
        JavaScriptFiles="$(SolutionDir)js\juserinteraction.js"
        ObfuscateJavaScript="FoSho"
        PreserveAllSemicolons="Yeah"
        DisableOptimizations="Nope"
        EncodingType="Default"
        DeleteJavaScriptFiles="false"
        JavaScriptOutputFile="$(TempBuildDir)js/juserinteraction.min.js"
        LoggingType="ALittleBit" />
    <CompressorTask
      Condition="'%(CssFiles.Identity)' != ''"
      CssFiles="%(CssFiles.Identity)"
      DeleteCssFiles="false"
      CssOutputFile="%(CssFiles.Identity)"
      CssCompressionType="YuiStockCompression"
      EncodingType="Default"
      LoggingType="ALittleBit" />
  </Target>

What I get is a copy of the source file, i.e. "$(SolutionDir)js\juserinteraction.js" and a new file called juserinteraction.min.js with 0 length.

Does it make sense for you?
Mar 6, 2009 at 8:16 PM
Had similar issue and found 2 things that fixed it for me
  • Added ThreadCulture to task
  • Made sure file path did not contain spaces.
Mar 9, 2009 at 11:18 AM
Thanks.

What do you mean by "Adding ThreadCulture to task"?


Coordinator
Mar 9, 2009 at 11:51 AM
In the latest source code (note: NOT the latest release in the 'Releases tab') there is a new Task Property that allows u to set the ThreadCulture.
Mar 9, 2009 at 3:43 PM
Thanks a lot both!!! Working great!!! It was a problem with spanish OS.

In case someone is interested, here is the configuration used:


<Target Name="AfterMerge">
    <!-- Create the list of files: you can create an explicit semi-colon delimited list or use wildcards as below -->
    <CreateItem Include="$(TempBuildDir)js\*.js">
      <Output TaskParameter="Include" ItemName="JavaScriptFiles" />
    </CreateItem>
    <CreateItem Include="$(TempBuildDir)theme\*.css">
      <Output TaskParameter="Include" ItemName="CssFiles" />
    </CreateItem>
    <!-- Execute CompressorTask for each file in the list -->
    <CompressorTask
      Condition="'%(JavaScriptFiles.Identity)' != ''"
        JavaScriptFiles="%(JavaScriptFiles.Identity)"
        ObfuscateJavaScript="FoSho"
        PreserveAllSemicolons="Yeah"
        DisableOptimizations="Nope"
        EncodingType="Default"
      ThreadCulture="es-ES"
        DeleteJavaScriptFiles="false"
        JavaScriptOutputFile="%(JavaScriptFiles.Identity)"
        LoggingType="ALittleBit" />
    <CompressorTask
      Condition="'%(CssFiles.Identity)' != ''"
      CssFiles="%(CssFiles.Identity)"
      DeleteCssFiles="false"
      CssOutputFile="%(CssFiles.Identity)"
      CssCompressionType="YuiStockCompression"
      EncodingType="Default"
      LoggingType="ALittleBit" />
  </Target>


Now... I would like to copy just certain number of html and js files from my build to a local virtual directory. Can this be accomplished within this deploy project?

For instance, I would like to add:
  • Two named html's: index.html and page1.html
  • All *.css files.
  • All *.js files excepting one (jquery-1.3.1-vsdoc.js)
Thanks again for your kind replies.
Mar 10, 2009 at 3:33 PM
Belitre, you should research a bit more before asking ;-)

Exclude entire folder from build:

<ItemGroup>
    <ExcludeFromBuild Include="$(SourceWebPhysicalPath)\docs\**\*.*" />
  </ItemGroup>

Remove file after build:

<Target Name="AfterBuild">
    <Delete Files="$(OutputPath)\js\jquery-1.3.1-vsdoc.js" />
  </Target>

Regards.
Mar 10, 2009 at 3:33 PM
Thank you very much, myself :-P
Coordinator
Mar 24, 2009 at 3:33 AM
Also Belitre, i've just uploaded some new code to enable files with a space in them. You'll need to download the code though. When people are happy, i'll make a new release.
Mar 28, 2009 at 3:36 PM
Great news!

Thanks for your great job. It is really useful.