如何从csproj中的AspNetCompiler的预编译中排除路径 [英] How to exclude path from precompilation for AspNetCompiler in csproj

查看:122
本文介绍了如何从csproj中的AspNetCompiler的预编译中排除路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

示例,我用-x

C:\Users\Test>C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_compiler.exe -v /Application.Web -p D:\Application.Web -x /Application.Web/Admin

运行后,此结果很好.但是当我翻译成csproj脚本时.

after run this result is fine. But when i translate to csproj scripts.

来自lib https://msdn.microsoft.com/zh-CN/library/ms164291.aspx

它没有参数将路径从预编译中排除.

It does not parameter to exclude path from precompilation.

当前在csproj文件上命令

Currently command on csproj file

<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'"> 
    <AspNetCompiler VirtualPath="Application.Web" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
<Target Name="AfterBuild">
    <RemoveDir Directories="$(BaseIntermediateOutputPath)" />
</Target>

推荐答案

您必须直接根据此博客文章 https://matthewrwilton.wordpress.com/2017/03/12/clusion-node_modules-folder-from-asp-net -编译/ 因为AspNetCompiler msbuild任务没有排除属性.

You have to call the aspnet_compiler.exe directly as per this blogpost https://matthewrwilton.wordpress.com/2017/03/12/excluding-node_modules-folder-from-asp-net-compilation/ because the AspNetCompiler msbuild task doesn't have a property for exclusions.

好事是您可以使用多个排除项来调用它,就像这样:

Good thing is that you can call it with multiple exclusions, like so:

<PropertyGroup>
    <exclusion1>some/path</exclusion1>
    <exclusion2>another/path</exclusion2>
</PropertyGroup>
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <Exec Command="$(MSBuildFrameworkToolsPath)aspnet_compiler.exe -v temp -p $(WebProjectOutputDir) -x $(exclusion1) -x $(exclusion2)"/>
</Target>

请记住,每个排除项仅使用一次-x参数.

Just remember to use the -x parameter once per exclusion.

这篇关于如何从csproj中的AspNetCompiler的预编译中排除路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆