MSBUILD目标未在增量构建中执行
我有一个目标,该目标将scss
编译成css
文件中的msbuild
中的文件。 问题是,当我构建项目时,目标通常不会执行。正如我发现的那样,问题是增量构建 - 因此msbuild
决定跳过执行任务。如何正确配置输入/输出以进行增量构建以与target
正确使用?
我有:
- 输入文件,位于
\ styles \
中。可以有很多文件夹,其中包含扩展名*。scss
- 输出文件是一个
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:
- Input files, that are located in
\Styles\
. There can be a lot of files with folders there with extension*.scss
- 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否希望增量构建不会忽略样式文件夹中的修改后的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.