YUI 压缩器和 TFS Build
我们有一个项目,其中 .js 和 .css 文件使用 YUI Compressor 进行压缩。一个非常好的工具。我们还使用 TFS 2010 作为构建服务器,每晚构建也会部署到我们的开发网站。
我们遇到的问题是 YUI 生成的文件导致“访问被拒绝”问题。这是因为之前已经生成了这样一个文件,并且它是项目的一部分,使其成为只读的。不过,我们可以将其从项目中删除,它应该会创建得很好。那么问题是生成的文件没有包含在实际的部署包中。
在本地,我没有问题,因为我有一个预构建事件命令脚本,它会删除现有文件。这显然不适用于构建服务器。也许 tfs 上下文用户缺乏权限,我不知道。
有没有人可能遇到过类似的问题?
21/11 更新: 这个问题可能有点模糊。为了简化,我们只想说我希望它像本地一样工作:
IF NOT $(ConfigurationName) == DEBUG DEL "$(ProjectDir)Styles\styles.min.css
IF NOT $(ConfigurationName) == DEBUG DEL "$(ProjectDir)JavaScript\script.min.js
这是在项目属性 -> 下的预构建命令事件行中定义的。构建活动。
该脚本在 YUI 文件生成之前删除了文件,因此没有要覆盖的文件。难道执行TFS-build的用户上下文没有足够的修改权限就这么简单吗?
解决方案:
我们最终在预构建事件中得到了以下代码:
attrib -r "$(ProjectDir)Styles\styles.min.css"
attrib -r "$(ProjectDir)JavaScript\script.min.js"
IF NOT $(ConfigurationName) == Debug $(MSBuildBinPath)\msbuild.exe "$(ProjectDir)Config\MSBuild\BuildSettings.xml"
/Mattias
We have a project where the .js and .css files gets compressed with YUI Compressor. A very good tool. We also use TFS 2010 as a build server with nightly builds that also deploys to our dev web site.
The problem we're having is that the file YUI generates causes a "Access denied"-problem. This is because there already is such a file generated from before, and that it's a part of the project, making it read-only. We can however remove it from the project and it should create fine. The problem then is that the generated file doesnt get included in the actual deploy package.
Locally i have no problem because i have a pre build event command script, which deletes the existing files. This apparently doesnt work on the build server. Maybe the tfs context user lacks permission, i dont know.
Is there anyone who might have had similiar problems?
Update 21/11:
The question may be abit vague. To simplify, lets just say i want this to work as it does locally:
IF NOT $(ConfigurationName) == DEBUG DEL "$(ProjectDir)Styles\styles.min.css
IF NOT $(ConfigurationName) == DEBUG DEL "$(ProjectDir)JavaScript\script.min.js
This is defined in the pre-build command event line, under Project properties -> Build events.
The script removes the files before the YUI-file generation, and thus there is no file to overwrite. Could it be that simple that the user context that executes the TFS-build have insufficent modify rights?
SOLUTION:
We ended up with the following code in the pre-build event:
attrib -r "$(ProjectDir)Styles\styles.min.css"
attrib -r "$(ProjectDir)JavaScript\script.min.js"
IF NOT $(ConfigurationName) == Debug $(MSBuildBinPath)\msbuild.exe "$(ProjectDir)Config\MSBuild\BuildSettings.xml"
/Mattias
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果这些文件是项目的一部分并从 TFS 存储库下载,如果您需要对它们进行任何处理(例如删除),请首先始终删除只读标志。因此,在您的脚本中,首先执行以下操作:
之后应该能够很好地删除它们。这可能不是权限问题,因为用于下载文件的帐户也是用于删除文件的帐户。
If the files are part of your project and downloaded from the TFS repository, first always remove te read-only flag if your need to do any processing on them, for example deletion. So in your script, first do:
Should be able to delete them fine after that. It is probably not a permission issue, since the account that is used to download the files is also the account used to delete them.