MSBUILD目标未在增量构建中执行

发布于 2025-01-23 05:52:23 字数 995 浏览 1 评论 0原文

我有一个目标,该目标将scss编译成css文件中的msbuild中的文件。 问题是,当我构建项目时,目标通常不会执行。正如我发现的那样,问题是增量构建 - 因此msbuild决定跳过执行任务。如何正确配置输入/输出以进行增量构建以与target正确使用?

我有:

  1. 输入文件,位于\ styles \中。可以有很多文件夹,其中包含扩展名*。scss
  2. 输出文件是一个wwwroot \ css \ ain.css

对MSBUILD配置的看法:

<ItemGroup>
    <SCSSFiles Include="Styles\**\*.scss" />
    <CSSFile Include="wwwroot\css\main.css" />
</ItemGroup>
<Target Name="CompileGlobalSass" BeforeTargets="Compile" Inputs="@(SCSSFiles)" Outputs="@(CSSFile)">
    <Message Text="++++++++++ Compiling global SCSS files" Importance="high" />
    <Exec Command="npm run sass -- Styles:wwwroot/css" />
</Target>

我 对此进行测试,我右键单击我的项目,然后选择build。第一次看到我的自定义消息。然后,我更改任何scss文件,然后再次选择build - 现在未显示消息,我的更改未转录为main.css.css

I have a target, that compiles scss into css files in Msbuild.
The issue is that when I build the project the target is often not executed. As I found out, the problem is incremental builds - so msbuild decides to skip executing the task. How do I correctly configure Inputs/Outputs for incremental build to work properly with Target?

I have:

  1. Input files, that are located in \Styles\. There can be a lot of files with folders there with extension *.scss
  2. Output file is one wwwroot\css\main.css

My take on msbuild configuration:

<ItemGroup>
    <SCSSFiles Include="Styles\**\*.scss" />
    <CSSFile Include="wwwroot\css\main.css" />
</ItemGroup>
<Target Name="CompileGlobalSass" BeforeTargets="Compile" Inputs="@(SCSSFiles)" Outputs="@(CSSFile)">
    <Message Text="++++++++++ Compiling global SCSS files" Importance="high" />
    <Exec Command="npm run sass -- Styles:wwwroot/css" />
</Target>

When I try to test this, I right click on my project and select Build. The first time I see my custom message. Then I change any scss file and select Build again - now the message is not displayed and my changes are not transpiled into main.css

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

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

发布评论

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

评论(1

蓝礼 2025-01-30 05:52:23

您是否希望增量构建不会忽略样式文件夹中的修改后的SCSS文件?如果修改了SCSS文件,请单击“构建”,将执行CompileGlobalsass目标?

您可以尝试在项目文件中添加&lt; upTodateCheckInput includs =“ styles/**/*。scss”/&gt;

Do you want incremental builds will not ignore modified scss files in the Styles folder? If the scss file is modified, click Build, the CompileGlobalSass target will be executed?

You can try adding <UpToDateCheckInput Include="Styles/**/*.scss"/> in your project file.

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