我们如何将ajaxmin创建的文件包含在MSBuild创建的msdeploy包中

发布于 2024-10-01 09:15:00 字数 1968 浏览 7 评论 0原文

我们使用 ajaxmin 从所有 .js 文件创建 .min.js 文件。我们编辑了项目的 .csproj 文件并添加了以下内容:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
    <ItemGroup>
        <JS Include="**\*.js" Exclude="**\*.min.js" />
    </ItemGroup>
    <AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" />
</Target>

当我们在工作站上构建站点并且可以在站点中使用 .min.js 文件时,这非常有用。当我们在该任务中检查此项目时,它也在 msbuild 服务器上运行,但 ajaxmin 生成的 .min.js 文件不会复制到我们使用的 tfs2010 Rolling Build 的放置位置。这些 .min.js 文件也不包含在我们在此滚动构建期间创建的包中,并且该包也被复制到放置位置。只有项目中包含的文件才会用于包并复制到放置位置。

我们用于创建包的 MSBuild 参数如下:

/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=InProc /p:CreatePackageOnPublish=True /p:MSDeployServiceURL=localhost

我尝试了多种方法,例如添加额外的构建任务以将所有 .min.js 文件复制到创建包的位置。我还尝试了以下网址 http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageInclusionExtraFilesOrExducingSpecificFiles .aspx 将此文件与以下内容包含在我的 .csproj 文件中:

<PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
    <ItemGroup>
        <_CustomFiles Include="**\*.min.js" />
        <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
            <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Target>

还有其他人也遇到此问题吗?或者有人知道如何将 *.min.js 文件包含在 msdeploy 包中并使文件复制到投放地点?

We use ajaxmin to create .min.js files from all our .js files. We have edited the .csproj file of the project and added following:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\MicrosoftAjax\ajaxmin.tasks" />
<Target Name="AfterBuild">
    <ItemGroup>
        <JS Include="**\*.js" Exclude="**\*.min.js" />
    </ItemGroup>
    <AjaxMin JsSourceFiles="@(JS)" JsSourceExtensionPattern="\.js$" JsTargetExtension=".min.js" />
</Target>

This works great when we build the site on our workstation and the .min.js files can be used in the site. When we check this project in this task runs also on the msbuild server but the .min.js files generated by ajaxmin are not copied to the drop location of the tfs2010 Rolling Build we use. These .min.js files are also not included into the package we create during this rolling build and which is also copied to the drop location. Only the files included into the project are used for the package and copied to the drop location.

The MSBuild Arguments we use to create the package are the following:

/p:DeployOnBuild=True /p:DeployTarget=MsDeployPublish /p:MSDeployPublishMethod=InProc /p:CreatePackageOnPublish=True /p:MSDeployServiceURL=localhost

I've tried several things as adding an extra build task to copy all the .min.js files to the location where the package is created. I tried also the following url http://sedodream.com/2010/05/01/WebDeploymentToolMSDeployBuildPackageIncludingExtraFilesOrExcludingSpecificFiles.aspx to include this files with the following in my .csproj file:

<PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
      CustomCollectFiles;
      $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
<Target Name="CustomCollectFiles">
    <ItemGroup>
        <_CustomFiles Include="**\*.min.js" />
        <FilesForPackagingFromProject  Include="%(_CustomFiles.Identity)">
            <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
        </FilesForPackagingFromProject>
    </ItemGroup>
</Target>

Has anyone else also this problem or does anyone have an idea how to include the *.min.js files in the msdeploy package and make the files copy to the drop location?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅沫记忆 2024-10-08 09:15:00

您错过了目标目录,因此您所要做的就是为脚本文件夹、源和目标中的每个脚本创建对文件夹,以确保您没有根据脚本文件夹结构将所有 min 文件复制到项目中的每个文件夹中您的项目的任何方式,我写一篇文章以及谁如何做到这一点,您也可以下载执行此操作的项目,http://mohamedradwan.wordpress.com/2010/11/12/如何包含-minify-files-or-custome-files-with-web-pagckage-or-ms-deploy-package/

谢谢

You missed the destination directory so all you have to do is creating pair folders for each script in your script folder, source and destination to make sure you didn't copy all the min files to each folder in your project according to the script folder structure of your project, any way I write an article and who how to do that, you can also download project that do that, http://mohamedradwan.wordpress.com/2010/11/12/how-to-include-minify-files-or-custome-files-with-web-pagckage-or-ms-deploy-package/

Thanks

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文