Copy the minified files when publishing

Oct 27, 2011 at 3:35 PM

Hi All,

I have set up YUICompressor in my Visual Studio.

In my script directory I see my compressed script.

But when I right click the solution and click publish, the compressed script is not copied to the publish folder.

Can I modify the task to do this? An how would i do this?

 

thanks

Coordinator
Oct 28, 2011 at 3:41 AM

Hi Ianmec,

 

it really depends on your source control. The short answer is -> yes u can. Add an empty file to the solution which will hold the minified script. When u define the TARGET file (where the minified script will go), give that empty file. This time, the file will now contain some content.

 

The problem is that the file was not part of the soution .. and the Publish command checks to see what files are listed in the solution .. not in a folder or folders. In effect -> the publish command has NO IDEA that there's a minified script file.

 

Now I said that it depends on your source control. Why? Well, TFS for example makes locked files, READ ONLY. so if u try and update an existing file which is TFS-LOCKED, then it will prolly error. So then u need to either manually check the file out or get your hands dirty with TFS and call the TFS api to check out the file (or target files), etc. etc. etc…..

 

What I've been doing is handling the minification during a TFS CI Build instead. Well, it's been a while since I did that actually. These days I used SQUISHIT (it's on nuget) which (optionally) uses YUICompressor.NET.

Oct 28, 2011 at 11:04 AM

Hi purekrome,

Thanks for the response. I was hoping to stay away from including the minified files in project because i need to keep the version numbers in the file names.

I think the best route to take will be to setup a Build script on the CI box and have the build script do all it needs to.

thanks for the help

regards

Coordinator
Oct 28, 2011 at 1:24 PM

pleasure :)

fwiw, we append buld version numbers to the css file in our html.

eg. Url.StyleSheet("main.css");

and that custom html helper then appends a build number, like ConfigurationManager.AppSettings["BuildVersion"] to the end of the url.

eg. /css/main.css?v=1234

so if we need to make sure people get a fresh copy of the css, etc… we up the build number.

gl!

From: ianmec [email removed]
Sent: Friday, 28 October 2011 9:04 PM
To: Justin Adler
Subject: Re: Copy the minified files when publishing [YUICompressor:277426]

From: ianmec

Hi purekrome,

Thanks for the response. I was hoping to stay away from including the minified files in project because i need to keep the version numbers in the file names.

I think the best route to take will be to setup a Build script on the CI box and have the build script do all it needs to.

thanks for the help

regards