开发者

Permission error when minifying JS/CSS from MSBuild output

I’m adding a post build task to run the Ajax Minifier (ajaxMin.exe) whenever a relase build of a project is conducted. I’ve added the code to the project to compress all CSS and JavaScript, but when triggering a build on the TFS build server I get lots of build errors in the BuildLog.txt with the message:

error : The Microsoft Ajax Minifier does not have permission to write to JS[filename].js

I get one message for each JavaScript and CSS file and rightly enough loking at the build output, no minification has taken place. The project is under source control, but I thought being a post build task, this wouldn’t matter as its minifying the output on the build server, not the source files themselves? The code added to my .csproj is as follows:

&开发者_StackOverflow社区lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.tasks" />
  <Target Name="AfterBuild" Condition=" '$(ConfigurationName)'=='Release' ">
    <ItemGroup>
      <JsFilesRelease Include="**\*.js" Exclude="**\*.min.js" />
      <CssFilesRelease Include="**\*.css" />
    </ItemGroup>
    <AjaxMin JsSourceFiles="@(JsFilesRelease)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".js"
         CssSourceFiles="@(CssFilesRelease)" CssSourceExtensionPattern="\.css$" CssTargetExtension=".css"   />
  </Target>

Is there any way I can get around this restriction? I want to ensure that all outputted files from the above are minified and it seems its only the permissions that are preventing it.

Thanks


With your code, the Ajax minifier will minify any js and css files in the working directory your built takes place and its subfolders. You can debug by printing the working directory before your AjaxMin task :

<Message Text="MSBuildProjectDirectory: $(MSBuildProjectDirectory)"/>

I think you should specify a more precise path to your output directory than "**". Are you working with VSS?

I do the same but with the Yui Compressor task (http://yuicompressor.codeplex.com/) instead of the MicrosoftAjax. You can find a study over the compressors here : http://coderjournal.com/2010/01/yahoo-yui-compressor-vs-microsoft-ajax-minifier-vs-google-closure-compiler/ I work with svn, CC.net and MSBuild.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜