如何让它自动在我的所有文件上运行?适用于 Visual Studio 的 YUI 压缩器

发布于 2024-09-01 04:05:19 字数 2364 浏览 2 评论 0原文

编辑 4(编辑 1 到 3 已解决,已删除)

我的最后一个问题是我想要多个目标,但它似乎不起作用。我必须将它们全部粘贴到同一个目标中,这有点糟糕,因为它会很好地使用不同的名称,所以我必须更改一些我可以只查看目标名称的东西。

您好,

我正在尝试获取我的 MsBuild,它可以工作......如果我的所有内容都在同一个目标标签中。如果我有多个标签,它只会执行第一个标签,仅此而已。其他目标都没有完成。

<Target Name="Test1">
    <ItemGroup>
      <JavaScriptFiles Remove="@(JavaScriptFiles)" />
  <JavaScriptFiles Include="..\PathHere\Javascript.js"/>

</ItemGroup>
<CompressorTask
      JavaScriptFiles="%(JavaScriptFiles.Identity)"
      ObfuscateJavaScript="True"
      PreserveAllSemicolons="False"
      DisableOptimizations="Nope"
      EncodingType="Default"
      DeleteJavaScriptFiles="false"
      LineBreakPosition="-1"
      JavaScriptOutputFile="../Path/Here/(JavaScriptFiles.FileName).min.js"
      LoggingType="ALittleBit"
      ThreadCulture="en-au"
      IsEvalIgnored="false"
        />

<ItemGroup>    
  <JavaScriptFiles Remove="@(JavaScriptFiles)" />
   <JavaScriptFiles Include="..\PathHere\Javascript2.js"/>

</ItemGroup>
<CompressorTask
      JavaScriptFiles="%(JavaScriptFiles.Identity)"
      ObfuscateJavaScript="True"
      PreserveAllSemicolons="False"
      DisableOptimizations="Nope"
      EncodingType="Default"
      DeleteJavaScriptFiles="false"
      LineBreakPosition="-1"
      JavaScriptOutputFile="../Path/Here/%(JavaScriptFiles.FileName).min.js"
      LoggingType="ALittleBit"
      ThreadCulture="en-au"
      IsEvalIgnored="false"
        />


  </Target>

所以上面的方法有效。如果我这样做,

    <Target Name="Test2">

        <ItemGroup>    
          <JavaScriptFiles Remove="@(JavaScriptFiles)" />
           JavaScriptFiles Include="..\PathHere\Javascript3.js"/>
    </ItemGroup>
    <CompressorTask
          JavaScriptFiles="%(JavaScriptFiles.Identity)"
          ObfuscateJavaScript="True"
          PreserveAllSemicolons="False"
          DisableOptimizations="Nope"
          EncodingType="Default"
          DeleteJavaScriptFiles="false"
          LineBreakPosition="-1"
          JavaScriptOutputFile="../Path/Here/%(JavaScriptFiles.FileName).min.js"
          LoggingType="ALittleBit"
          ThreadCulture="en-au"
          IsEvalIgnored="false"
            />

</Target>

那么第一个目标将会消失,而上面的目标将不会执行任何操作。

Edit 4 (Edit 1 to 3 removed as they where solved)

My last problem is that I would like multiple targets but it does not seem to work. I have to stick them all into the same target what kinda sucks since it would nice to different names so I got to change something I can just look at the target name.

Hi

I am trying to get my MsBuild and it works....if all my stuff is in the same target tag. If I have multiple tags it only does the first one and that's it. None of the other targets are done.

<Target Name="Test1">
    <ItemGroup>
      <JavaScriptFiles Remove="@(JavaScriptFiles)" />
  <JavaScriptFiles Include="..\PathHere\Javascript.js"/>

</ItemGroup>
<CompressorTask
      JavaScriptFiles="%(JavaScriptFiles.Identity)"
      ObfuscateJavaScript="True"
      PreserveAllSemicolons="False"
      DisableOptimizations="Nope"
      EncodingType="Default"
      DeleteJavaScriptFiles="false"
      LineBreakPosition="-1"
      JavaScriptOutputFile="../Path/Here/(JavaScriptFiles.FileName).min.js"
      LoggingType="ALittleBit"
      ThreadCulture="en-au"
      IsEvalIgnored="false"
        />

<ItemGroup>    
  <JavaScriptFiles Remove="@(JavaScriptFiles)" />
   <JavaScriptFiles Include="..\PathHere\Javascript2.js"/>

</ItemGroup>
<CompressorTask
      JavaScriptFiles="%(JavaScriptFiles.Identity)"
      ObfuscateJavaScript="True"
      PreserveAllSemicolons="False"
      DisableOptimizations="Nope"
      EncodingType="Default"
      DeleteJavaScriptFiles="false"
      LineBreakPosition="-1"
      JavaScriptOutputFile="../Path/Here/%(JavaScriptFiles.FileName).min.js"
      LoggingType="ALittleBit"
      ThreadCulture="en-au"
      IsEvalIgnored="false"
        />


  </Target>

So the above works. If I do this

    <Target Name="Test2">

        <ItemGroup>    
          <JavaScriptFiles Remove="@(JavaScriptFiles)" />
           JavaScriptFiles Include="..\PathHere\Javascript3.js"/>
    </ItemGroup>
    <CompressorTask
          JavaScriptFiles="%(JavaScriptFiles.Identity)"
          ObfuscateJavaScript="True"
          PreserveAllSemicolons="False"
          DisableOptimizations="Nope"
          EncodingType="Default"
          DeleteJavaScriptFiles="false"
          LineBreakPosition="-1"
          JavaScriptOutputFile="../Path/Here/%(JavaScriptFiles.FileName).min.js"
          LoggingType="ALittleBit"
          ThreadCulture="en-au"
          IsEvalIgnored="false"
            />

</Target>

Then the first target will go and the above one will do nothing.

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

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

发布评论

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

评论(3

相思故 2024-09-08 04:05:19

看起来这是一个很好的起点:

http://yuicompressor.codeplex.com/

他们吹嘘:

Visual Studio 构建后事件集成! :)(有详细说明...

Looks like this is a good place to start:

http://yuicompressor.codeplex.com/

They boast:

Visual Studio post-build event intergration! :) (with detailed instructions...

冷…雨湿花 2024-09-08 04:05:19

我不确定,但看起来 MSBuild 变量访问存在一些混乱。使用 msbuild 可以通过三种方式访问​​变量。

$()  Extracts the value of a property
@()  Extracts the value of an item as a list, that is, vector
%()  Extracts value of an item as a single string, that is, scalar

看起来您实际上想在使用 %() 的地方使用 @() 但我承认我很难准确理解您的问题是。你说它“什么也不做”,但它很可能正在做某事,即使它看起来什么也没做。

更多信息

I'm not sure, but it looks like there is some confusion about MSBuild variable access. There are three ways to access variables with msbuild.

$()  Extracts the value of a property
@()  Extracts the value of an item as a list, that is, vector
%()  Extracts value of an item as a single string, that is, scalar

It looks like you actually want to be using @() where you are using %() but I'll confess I'm having a hard time understanding exactly what your problem is. You said it "will do nothing" but chances are it's doing something, even if it doesn't appear to be doing anything.

more here

何止钟意 2024-09-08 04:05:19

您应该能够通过修改项目的 .proj 文件中的 msbuild 脚本来完成此操作。

以下是 MsBuild 的链接 -

http://msdn.microsoft.com/ en-us/library/0k6kkbsd.aspx

享受吧!

You should be able to do this by modifying the msbuild script in the .proj file of your project.

Here is a link to MsBuild --

http://msdn.microsoft.com/en-us/library/0k6kkbsd.aspx

Enjoy!

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